# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
226206 | DS007 | Asceticism (JOI18_asceticism) | C++14 | 37 ms | 1952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define long long long
using namespace std;
const int N = 1e5+5;
const int M = 1e9+7;
long modpow(long a, long b) {
long ret = 1;
for( ; b; b >>= 1) {
if(b & 1) ret = ret * a % M;
a = a * a % M;
}
return ret;
}
int n, k;
long fac[N], inv[N];
long ncr(int a, int b) {
return fac[a] * inv[b] % M * inv[a - b] % M;
}
int main() {
fac[0] = inv[0] = 1;
for(int i = 1; i < N; i++) {
fac[i] = fac[i-1] * i % M;
inv[i] = modpow(fac[i], M - 2);
}
scanf("%d %d", &n, &k);
long ans = 0;
for(int i = 0; i <= k; i++) {
long l = ncr(n, i), r = modpow(k - i, n);
if(i < k) r = (r - modpow(k - i - 1, n) + M) % M;
l = l * r % M;
if(i & 1) ans = (ans - l + M) % M;
else ans = (ans + l) % M;
}
printf("%lld\n", ans);
return 0;
}
컴파일 시 표준 에러 (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... |