Submission #19916

#TimeUsernameProblemLanguageResultExecution timeMemory
19916xdoju순열 (kriii4_T)C++14
100 / 100
845 ms1084 KiB
#include <stdio.h> const int MOD = 1000000007; int mul(int x, int y){ return (long long)x * y % MOD; } int power(int x, int y){ if(y == 0) return 1; int r = power(x, y / 2); r = mul(r, r); if(y % 2 == 1) r = mul(r, x); return r; } int modinv(int x){ return power(x, MOD - 2); } int main(){ int N, K; scanf("%d%d", &N, &K); int v = 1; for(int i = 1; i <= N + 1; i++) v = mul(v, i); // fac(N + 1) v = mul(v, N + 1); int ans = 0; for(int k = 1; k <= N; k++){ v = mul(v, k); v = mul(v, modinv(k + 1)); v = mul(v, N - k + 1); v = mul(v, modinv(N - k + 2)); if(k >= K + 1) ans = (ans + v) % MOD; } printf("%d\n", ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...