Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求助:为什么TLE?这道题目我的理解是求组合数C(m,n) 我的想法把每次乘积的值去掉之后取末位,再次去乘以被乘数。 #include<stdio.h> int main() { int n,m,i,sum; while(scanf("%d%d",&n,&m)!=EOF) { sum=n; for(i=n-1;i>n-m;i--) { sum*=i; while(sum%10==0) //删除0 sum/=10; sum%=10; //取末位 } printf("%d\n",sum); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator