結果

問題 No.786 京都大学の過去問
ユーザー masamasa
提出日時 2019-02-26 10:38:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 63,064 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 13:06:16
合計ジャッジ時間 1,502 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <array>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

using namespace std;
template<class T> int maxReturn(T a, T b) {if (a > b) {return a;} else {return b;}}
template<class T> int minReturn(T a, T b) {if (a < b) {return a;} else {return b;}}



int main(void){
    int N;
    cin >> N;
    vector<long> dp;
    
    REP(i, N) {
        if (i == 0 || i == 1) dp.push_back(i+1);
        else dp.push_back(dp[i-1] + dp[i-2]);
    }
    
    cout << dp[N-1] << endl;
}
0