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 |
WA 无数遍 终于写出的0ms 直接从前向后扫描能过 从后向前据WA了#include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; #define mmax 10000000 typedef __int64 ll; ll ans(ll x,ll y) { if(y==0) return 1; ll i,j; ll ans=1; j=1; for(i=x-y+1;i<=x;i++) { ans=ans*i; // printf("%I64d ",i); while(ans%j==0&&j<=y) { ans/=j; j++; } } return ans; } int main() { ll n,k; while(scanf("%I64d %I64d",&n,&k)!=EOF&&(n!=0||k!=0)) { if(2*k>n) printf("%I64d\n",ans(n,n-k)); else printf("%I64d\n",ans(n,k)); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator