Submission #19990

#TimeUsernameProblemLanguageResultExecution timeMemory
19990ainta순열 (kriii4_T)C++98
100 / 100
891 ms16864 KiB
#include<stdio.h> #include<algorithm> using namespace std; int n, K; long long F[1010000], InvF[1010000], Mod = 1000000007, Res; long long Pow(long long a, int b){ long long r = 1; while(b){ if(b&1)r=r*a%Mod; a=a*a%Mod;b>>=1; } return r; } int main(){ int L, i; scanf("%d%d",&n,&K); F[0]=InvF[0]=1; for(i=1;i<=n+1;i++){ F[i]=F[i-1]*i%Mod; InvF[i] = Pow(F[i],Mod-2); } for(L=K+1;L<=n;L++){ Res = (Res + F[L]*F[n-L+1]%Mod*F[n+1]%Mod*InvF[L+1]%Mod*InvF[n-L])%Mod; } printf("%lld\n",Res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...