# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
361738 | dolphingarlic | Asceticism (JOI18_asceticism) | C++14 | 24 ms | 380 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 ll MOD = 1e9 + 7;
ll expo(ll base, ll pow) {
ll ans = 1;
while (pow) {
if (pow & 1) ans = (ans * base) % MOD;
base = (base * base) % MOD;
pow >>= 1;
}
return ans;
}
int main() {
int n, k;
scanf("%d %d", &n, &k);
ll ans = 0, choose = 1, neg = 1;
for (int i = 0; i <= k; i++) {
ans = (ans + neg * choose % MOD * expo(k - i, n) % MOD) % MOD;
choose = choose * (n + 1 - i) % MOD * expo(i + 1, MOD - 2) % MOD;
neg = MOD - neg;
}
printf("%lld", 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... |