# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
19916 | | xdoju | 순열 (kriii4_T) | C++14 | | 845 ms | 1084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |