結果

問題 No.44 DPなすごろく
ユーザー tenman
提出日時 2019-01-03 23:30:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 326 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 165,632 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-23 22:58:01
合計ジャッジ時間 2,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;

  ll dp[N+1];
  dp[1] = 1;
  dp[2] = 2;
  for (int i = 3; i <= N; i++) {
    dp[i] = dp[i-1] + dp[i-2];
  }

  cout << dp[N] << endl;
  return 0;
}
0