# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
420768 | qwerasdfzxcl | Asceticism (JOI18_asceticism) | C++14 | 1 ms | 252 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 <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MOD = 1e9+7;
ll pw(ll a, ll e){
if (!e) return 1;
ll ret = pw(a, e/2);
if (e&1) return ret*ret%MOD*a%MOD;
return ret*ret%MOD;
}
int main(){
int n, k;
scanf("%d %d", &n, &k);
ll ans = 0, tmp = 1;
for (int i=k;i;i--){
ans += pw(i, n)*tmp;
tmp = (-tmp*(n+1-k+i)%MOD)*pw(k-i+1, MOD-2)%MOD;
if (tmp<0) tmp += MOD;
}
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |