Submission #21295

#TimeUsernameProblemLanguageResultExecution timeMemory
21295suzy순열 (kriii4_T)C++14
100 / 100
369 ms8928 KiB
#include <stdio.h> #define MOD 1000000007 typedef long long lli; lli fac[1000002]; lli pw(lli n, lli x) { if(x==0) return 1; if(x%2) return n*pw(n,x-1)%MOD; else { lli ret=pw(n,x/2); return ret*ret%MOD; } } int main() { lli n, k; fac[0]=1; for(lli i=1;i<=1000001;i++) fac[i]=fac[i-1]*i%MOD; scanf("%lld %lld",&n,&k); k++; if(k>n) { puts("0"); return 0; } lli res=0, ncl=fac[n+1]*pw(fac[n-k],MOD-2)%MOD*pw(fac[k+1],MOD-2)%MOD; for(lli l=k;l<=n;l++) { res+=(n-l+1)*fac[l]%MOD*fac[n-l]%MOD*ncl%MOD; res%=MOD; ncl=ncl*(n-l)%MOD*pw(l+2,MOD-2)%MOD; } printf("%lld\n",res); return 0; }

Compilation message (stderr)

T.cpp: In function 'int main()':
T.cpp:19:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n,&k); k++;
                          ^

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...