結果

問題 No.1877 俺自身が線グラフになることだ
ユーザー ruthenruthen
提出日時 2022-03-18 22:10:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 166,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 09:59:30
合計ジャッジ時間 2,358 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include "debug.hpp"
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

#include <atcoder/modint>
using namespace atcoder;
using mint = modint1000000007;
ostream &operator<<(ostream &os, const mint &p) { return os << p.val(); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if (N <= 2) {
        cout << 0 << '\n';
        return 0;
    }
    V<mint> dp(N + 1, 0);
    dp[0] = 1;
    for (int i = 0; i < N - 2; i++) {
        // w = i+3
        for (int j = 0; j <= N; j++) {
            if (j + i + 3 <= N) dp[j + i + 3] += dp[j];
        }
    }
    show(dp);
    cout << dp[N] << '\n';
    return 0;
}
0