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: #include<stdio.h> int main() { int n,m; while(1) { scanf("%d%d",&n,&m); if(!n)break; double result=1; if(n<2*m)m=n-m; for(int i=1;i<=m;i++) result=result*(n+1-i)/i; printf("%.0lf\n",result); } return 0; } AC:0ms #include<stdio.h> int main() { unsigned n,m; while(1) { scanf("%d%d",&n,&m); if(!n)break; double result=1; if(n<2*m)m=n-m; for(int i=1;i<=m;i++) result=result*(n+1-i)/i; printf("%.0lf\n",result); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator