# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
361740 | dolphingarlic | Asceticism (JOI18_asceticism) | C++14 | 24 ms | 492 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 b, ll p) {
ll ans = 1;
while (p) {
if (p & 1) ans = (ans * b) % MOD;
b = (b * b) % MOD;
p >>= 1;
}
return ans;
}
int main() {
int n, k;
scanf("%d %d", &n, &k);
ll ans = 0, c = 1, d = 1;
for (int i = 0; i <= k; i++) {
ans = (ans + d * c % MOD * expo(k - i, n)) % MOD;
c = c * (n + 1 - i) % MOD * expo(i + 1, MOD - 2) % MOD;
d = MOD - d;
}
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... |