Submission #19820

#TimeUsernameProblemLanguageResultExecution timeMemory
19820Namnamseo순열 (kriii4_T)C++14
8 / 100
2000 ms16708 KiB
#include<cstdio> long long mans,c,mul[1000003],fac[1000003],a,b,i,j,s=1,ans,X=1e9+7; long long pow(long long aa,long long bb){ if(bb==0) return 1; long long ret=pow(aa,bb/2); ret=(ret*ret)%X; if(bb&1) ret=(ret*aa)%X; return ret; } long long com(long long aa,long long bb) { return fac[aa]*pow(fac[bb],X-2)%X*pow(fac[aa-bb],X-2)%X; } main() { scanf("%lld%lld",&a,&b); if(b>=a) { printf("0");return 0; } fac[0]=1; for(i=1;i<=a+1;i++)fac[i]=fac[i-1]*i%X; for(i=b+1;i<=a;i++) { mans+=fac[i]*fac[a-i+1]%X*com(a+1,i+1)%X; mans%=X; } printf("%lld",mans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...