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 |
Why WA?代码在2246就过了,这里就wa!#include<stdio.h> __int64 gcd(__int64 a,__int64 b) { if(a < b) { __int64 temp=a; a=b; b=temp; } __int64 c=a%b; while(c!=0) { a=b; b=c; c=a%b; } return b; } void main() { int m,n,i; __int64 sum1=1; __int64 sum2=1; while(scanf("%d%d",&m,&n),m||n) { sum1=1; sum2=1; if(n>m/2) n=m-n; for(i=1;i<=n;i++) { sum1=sum1*(m-i+1); sum2=sum2*i; __int64 d=gcd(sum1,sum2); sum1/=d; sum2/=d; } printf("%d things taken %d at a time is %I64d exactly.\n",m,n,sum1/sum2); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator