제출 #209794

#제출 시각아이디문제언어결과실행 시간메모리
209794FutymyCloneZapina (COCI20_zapina)C++14
110 / 110
164 ms1808 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 355;
const int mod = 1e9 + 7;

int n, f[N][N], g[N][N], C[N][N];

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int main(){
    scanf("%d", &n);
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (!i || !j || i == j) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
        }
    }

    f[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; j + k <= n; k++) {
                add(f[i + 1][j + k], 1LL * f[i][j] * C[n - j][k] % mod);
            }
        }
    }

    g[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; j + k <= n; k++) {
                if (k == i + 1) continue;
                add(g[i + 1][j + k], 1LL * g[i][j] * C[n - j][k] % mod);
            }
        }
    }

    int ans = f[n][n] - g[n][n];
    if (ans < 0) ans += mod;
    printf("%d", ans);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

zapina.cpp: In function 'int main()':
zapina.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...