# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
166225 | 2019-12-01T10:43:27 Z | georgerapeanu | Asceticism (JOI18_asceticism) | C++11 | 16 ms | 1144 KB |
#include <cstdio> using namespace std; const int NMAX = 1e5; const int MOD = 1e9 + 7; int n; int k; int fact[NMAX + 5]; int ifact[NMAX + 5]; int lgpow(int b,int e){ int p = 1; while(e){ if(e & 1){ p = 1LL * p * b % MOD; } b = 1LL * b * b % MOD; e >>= 1; } return p; } int comb(int n,int k){ return (1LL * (1LL * fact[n] * ifact[k] % MOD) * ifact[n - k] % MOD); } int main() { fact[0] = 1; for(int i = 1;i <= NMAX + 2;i++){ fact[i] = 1LL * i * fact[i - 1] % MOD; } ifact[NMAX + 2] = lgpow(fact[NMAX + 2],MOD - 2); for(int i = NMAX + 1;i >= 0;i--){ ifact[i] = 1LL * ifact[i + 1] * (i + 1) % MOD; } scanf("%d %d",&n,&k); int ans = 0; for(int i = 0;i < k;i++){ ans += 1LL * (i & 1 ? -1 : 1) * comb(n + 1,i) * lgpow(k - i,n) % MOD; if(ans < 0){ ans += MOD; } else if (ans >= MOD){ ans -= MOD; } } printf("%d\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1144 KB | Output is correct |
2 | Correct | 15 ms | 1016 KB | Output is correct |
3 | Correct | 4 ms | 1016 KB | Output is correct |
4 | Correct | 4 ms | 1016 KB | Output is correct |
5 | Correct | 4 ms | 1016 KB | Output is correct |
6 | Correct | 4 ms | 1016 KB | Output is correct |
7 | Correct | 4 ms | 1016 KB | Output is correct |
8 | Correct | 4 ms | 1016 KB | Output is correct |
9 | Correct | 4 ms | 1144 KB | Output is correct |
10 | Correct | 4 ms | 1016 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1144 KB | Output is correct |
2 | Correct | 15 ms | 1016 KB | Output is correct |
3 | Correct | 4 ms | 1016 KB | Output is correct |
4 | Correct | 4 ms | 1016 KB | Output is correct |
5 | Correct | 4 ms | 1016 KB | Output is correct |
6 | Correct | 4 ms | 1016 KB | Output is correct |
7 | Correct | 4 ms | 1016 KB | Output is correct |
8 | Correct | 4 ms | 1016 KB | Output is correct |
9 | Correct | 4 ms | 1144 KB | Output is correct |
10 | Correct | 4 ms | 1016 KB | Output is correct |
11 | Correct | 4 ms | 1144 KB | Output is correct |
12 | Correct | 4 ms | 1144 KB | Output is correct |
13 | Correct | 4 ms | 1016 KB | Output is correct |
14 | Correct | 4 ms | 1016 KB | Output is correct |
15 | Correct | 4 ms | 1144 KB | Output is correct |
16 | Correct | 4 ms | 1016 KB | Output is correct |
17 | Correct | 4 ms | 1016 KB | Output is correct |
18 | Correct | 4 ms | 1016 KB | Output is correct |
19 | Correct | 4 ms | 1016 KB | Output is correct |
20 | Correct | 4 ms | 1144 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1144 KB | Output is correct |
2 | Correct | 15 ms | 1016 KB | Output is correct |
3 | Correct | 4 ms | 1016 KB | Output is correct |
4 | Correct | 4 ms | 1016 KB | Output is correct |
5 | Correct | 4 ms | 1016 KB | Output is correct |
6 | Correct | 4 ms | 1016 KB | Output is correct |
7 | Correct | 4 ms | 1016 KB | Output is correct |
8 | Correct | 4 ms | 1016 KB | Output is correct |
9 | Correct | 4 ms | 1144 KB | Output is correct |
10 | Correct | 4 ms | 1016 KB | Output is correct |
11 | Correct | 4 ms | 1144 KB | Output is correct |
12 | Correct | 4 ms | 1144 KB | Output is correct |
13 | Correct | 4 ms | 1016 KB | Output is correct |
14 | Correct | 4 ms | 1016 KB | Output is correct |
15 | Correct | 4 ms | 1144 KB | Output is correct |
16 | Correct | 4 ms | 1016 KB | Output is correct |
17 | Correct | 4 ms | 1016 KB | Output is correct |
18 | Correct | 4 ms | 1016 KB | Output is correct |
19 | Correct | 4 ms | 1016 KB | Output is correct |
20 | Correct | 4 ms | 1144 KB | Output is correct |
21 | Correct | 4 ms | 1116 KB | Output is correct |
22 | Correct | 4 ms | 1144 KB | Output is correct |
23 | Correct | 4 ms | 1144 KB | Output is correct |
24 | Correct | 12 ms | 1144 KB | Output is correct |
25 | Correct | 4 ms | 1016 KB | Output is correct |
26 | Correct | 4 ms | 1144 KB | Output is correct |
27 | Correct | 4 ms | 1144 KB | Output is correct |
28 | Correct | 4 ms | 1016 KB | Output is correct |
29 | Correct | 4 ms | 1016 KB | Output is correct |
30 | Correct | 4 ms | 1016 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1144 KB | Output is correct |
2 | Correct | 15 ms | 1016 KB | Output is correct |
3 | Correct | 4 ms | 1016 KB | Output is correct |
4 | Correct | 4 ms | 1016 KB | Output is correct |
5 | Correct | 4 ms | 1016 KB | Output is correct |
6 | Correct | 4 ms | 1016 KB | Output is correct |
7 | Correct | 4 ms | 1016 KB | Output is correct |
8 | Correct | 4 ms | 1016 KB | Output is correct |
9 | Correct | 4 ms | 1144 KB | Output is correct |
10 | Correct | 4 ms | 1016 KB | Output is correct |
11 | Correct | 4 ms | 1144 KB | Output is correct |
12 | Correct | 4 ms | 1144 KB | Output is correct |
13 | Correct | 4 ms | 1016 KB | Output is correct |
14 | Correct | 4 ms | 1016 KB | Output is correct |
15 | Correct | 4 ms | 1144 KB | Output is correct |
16 | Correct | 4 ms | 1016 KB | Output is correct |
17 | Correct | 4 ms | 1016 KB | Output is correct |
18 | Correct | 4 ms | 1016 KB | Output is correct |
19 | Correct | 4 ms | 1016 KB | Output is correct |
20 | Correct | 4 ms | 1144 KB | Output is correct |
21 | Correct | 4 ms | 1116 KB | Output is correct |
22 | Correct | 4 ms | 1144 KB | Output is correct |
23 | Correct | 4 ms | 1144 KB | Output is correct |
24 | Correct | 12 ms | 1144 KB | Output is correct |
25 | Correct | 4 ms | 1016 KB | Output is correct |
26 | Correct | 4 ms | 1144 KB | Output is correct |
27 | Correct | 4 ms | 1144 KB | Output is correct |
28 | Correct | 4 ms | 1016 KB | Output is correct |
29 | Correct | 4 ms | 1016 KB | Output is correct |
30 | Correct | 4 ms | 1016 KB | Output is correct |
31 | Correct | 4 ms | 1144 KB | Output is correct |
32 | Correct | 10 ms | 1016 KB | Output is correct |
33 | Correct | 5 ms | 1144 KB | Output is correct |
34 | Correct | 6 ms | 1144 KB | Output is correct |
35 | Correct | 13 ms | 1016 KB | Output is correct |
36 | Correct | 16 ms | 1144 KB | Output is correct |
37 | Correct | 15 ms | 1144 KB | Output is correct |
38 | Correct | 5 ms | 1016 KB | Output is correct |
39 | Correct | 7 ms | 1144 KB | Output is correct |
40 | Correct | 8 ms | 1144 KB | Output is correct |