# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
206344 | 2020-03-03T02:51:34 Z | luciocf | Zapina (COCI20_zapina) | C++14 | 188 ms | 2424 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 705; const int mod = 1e9+7; int n; int dp[maxn][maxn]; int choose[maxn][maxn]; int fat[maxn]; int pot(int a, int b) { if (!b) return 1; int t = pot(a, b/2); if (b&1) return (1ll*a*((1ll*t*t)%mod))%mod; return (1ll*t*t)%mod; } void calc(void) { for (int i = 1; i <= n; i++) { choose[i][0] = 1; for (int j = 1; j <= i; j++) choose[i][j] = (((1ll*choose[i][j-1]*(i-j+1))%mod)*pot(j, mod-2))%mod; } } int main(void) { scanf("%d", &n); calc(); for (int i = 0; i <= n; i++) dp[i][0] = 1; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int l = 0; l <= j; l++) if (l != i) dp[i][j] = (1ll*dp[i][j] + (1ll*choose[j][l]*dp[i-1][j-l]))%mod; printf("%d\n", ((pot(n, n) + (mod-dp[n][n]))%mod)); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 504 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 504 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 504 KB | Output is correct |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 504 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 504 KB | Output is correct |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 96 ms | 1912 KB | Output is correct |
18 | Correct | 7 ms | 632 KB | Output is correct |
19 | Correct | 26 ms | 1272 KB | Output is correct |
20 | Correct | 5 ms | 504 KB | Output is correct |
21 | Correct | 126 ms | 1940 KB | Output is correct |
22 | Correct | 20 ms | 1144 KB | Output is correct |
23 | Correct | 7 ms | 624 KB | Output is correct |
24 | Correct | 33 ms | 1276 KB | Output is correct |
25 | Correct | 24 ms | 1144 KB | Output is correct |
26 | Correct | 41 ms | 1400 KB | Output is correct |
27 | Correct | 175 ms | 2296 KB | Output is correct |
28 | Correct | 175 ms | 2284 KB | Output is correct |
29 | Correct | 175 ms | 2296 KB | Output is correct |
30 | Correct | 179 ms | 2168 KB | Output is correct |
31 | Correct | 181 ms | 2276 KB | Output is correct |
32 | Correct | 183 ms | 2424 KB | Output is correct |
33 | Correct | 182 ms | 2296 KB | Output is correct |
34 | Correct | 183 ms | 2296 KB | Output is correct |
35 | Correct | 187 ms | 2296 KB | Output is correct |
36 | Correct | 186 ms | 2296 KB | Output is correct |
37 | Correct | 188 ms | 2296 KB | Output is correct |