Submission #20101

#TimeUsernameProblemLanguageResultExecution timeMemory
20101imsifile순열 (kriii4_T)C++98
100 / 100
821 ms16724 KiB
#include<stdio.h> #include<memory.h> #define mod 1000000007 #define inv(a) exp(a,mod-2) typedef long long lld; lld exp(lld a, lld b){ if(b==0)return 1; lld k=exp(a, b/2); k=(k*k)%mod; if(b%2)k=(k*a)%mod; return k; } lld fac[1001001], rfac[1001001]; void init(){ lld i; fac[0]=rfac[0]=1; for(i=1; i<=1000001; i++){ fac[i]=(fac[i-1]*i)%mod; rfac[i]=inv(fac[i]); } } lld comb(lld a, lld b){ return fac[a]*rfac[b]%mod*rfac[a-b]%mod; } lld n, k, sum; int main(){ lld i; init(); scanf("%lld%lld", &n, &k); for(i=k+1; i<=n; i++){ lld im = fac[n+1]*(n-i+1)%mod * inv(i+1); im = (im%mod+mod)%mod; sum += im, sum%=mod; } printf("%lld", sum); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...