結果

問題 No.44 DPなすごろく
ユーザー oooooba
提出日時 2021-09-18 22:40:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 637 bytes
コンパイル時間 1,198 ms
コンパイル使用メモリ 113,924 KB
最終ジャッジ日時 2025-01-24 15:49:37
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std; // NOLINT

int main() {
    int32_t n;
    cin >> n;
    vector<int64_t> dp(n + 1);
    dp[0] = 1;
    for (auto i = 1; i <= n; ++i) {
        int64_t t = 0;
        if (i - 1 >= 0)
            t += dp[i - 1];
        if (i - 2 >= 0)
            t += dp[i - 2];
        dp[i] = t;
    }
    cout << dp[n] << endl;
    return 0;
}
0