結果

問題 No.786 京都大学の過去問
ユーザー hokutohokuto
提出日時 2021-08-31 08:31:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 93,012 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 11:56:46
合計ジャッジ時間 1,428 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
using namespace std;
using ll = long long int;
#define chmax(x,y)  x = (x > (y)) ? x : (x = (y));
#define chmin(x,y)  x = (x < (y)) ? x : (x = (y));


int main(int argc, char const *argv[])
{
  int N; cin >> N;
  vector<ll> dp(N+1);
  dp[0] = 1;
  for(int i=0;i<N;++i)
  {
    if(i+1 <= N)dp[i+1] += dp[i];
    if(i+2 <= N)dp[i+2] += dp[i];
  }
  std::cout << dp[N] << std::endl;
}
0