Submission #19698

#TimeUsernameProblemLanguageResultExecution timeMemory
19698Namnamseo순열 (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; main() { scanf("%lld%lld",&a,&b); if(b>=a) { printf("0");return 0; } for(;b<=a-1;){ b++;ans=0; mul[a-b+1]=1; for(i=a-b;i>=1;i--) { mul[i]=mul[i+1]*i%X; } fac[0]=1; for(i=1;i<=a;i++)fac[i]=fac[i-1]*i%X; for(i=1;i<=a&&a-i>=0&&a-b+2-i>=1;i++) { ans+=i*b%X*fac[a-i]%X*mul[a-b+2-i]%X; ans%=X; } mans+=ans*(a-b+1)%X; mans%=X; } printf("%lld",mans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...