답안 #798700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798700 2023-07-31T01:04:07 Z raphaelp Zapina (COCI20_zapina) C++14
110 / 110
44 ms 2236 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<vector<long long>> Pascal(N + 2, vector<long long>(N + 2, 0));
    for (int i = 0; i <= N; i++)
    {
        Pascal[i][0] = 1;
    }
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N + 1; j++)
        {
            Pascal[i][j] = (Pascal[i - 1][j] + Pascal[i - 1][j - 1]) % 1000000007;
        }
    }
    long long tot = 1;
    for (int i = 0; i < N; i++)
    {
        tot = (tot * N) % 1000000007;
    }
    vector<vector<long long>> tab(N + 1, vector<long long>(N + 1, 0));
    tab[0][0] = 1;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            if (tab[i][j] == 0)
                continue;
            for (int k = 0; k <= N - j; k++)
            {
                if (k == i + 1)
                    continue;
                tab[i + 1][j + k] += tab[i][j] * Pascal[N - j][k];
                tab[i + 1][j + k] = tab[i + 1][j + k] % 1000000007;
            }
        }
    }
    tot += 1000000007;
    tot = (tot - tab[N][N]) % 1000000007;
    cout << tot;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 25 ms 1504 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 5 ms 684 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 29 ms 1748 KB Output is correct
22 Correct 4 ms 596 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 6 ms 724 KB Output is correct
25 Correct 5 ms 596 KB Output is correct
26 Correct 9 ms 852 KB Output is correct
27 Correct 40 ms 2132 KB Output is correct
28 Correct 42 ms 2132 KB Output is correct
29 Correct 42 ms 2132 KB Output is correct
30 Correct 42 ms 2132 KB Output is correct
31 Correct 42 ms 2132 KB Output is correct
32 Correct 42 ms 2132 KB Output is correct
33 Correct 43 ms 2132 KB Output is correct
34 Correct 44 ms 2132 KB Output is correct
35 Correct 43 ms 2132 KB Output is correct
36 Correct 44 ms 2228 KB Output is correct
37 Correct 44 ms 2236 KB Output is correct