結果

問題 No.786 京都大学の過去問
ユーザー tomorrowtomorrow
提出日時 2022-05-20 01:31:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 200,616 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 10:11:59
合計ジャッジ時間 2,476 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll inf = (1LL << 62);
template <typename T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T& a, const T& b)
{
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
ll dp[60];
int main()
{
    ll n;
    cin >> n;
    dp[0] = 1;
    dp[1] = 2;
    for (ll i = 2; i < n; ++i) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[n - 1] << endl;
}
0