結果

問題 No.44 DPなすごろく
ユーザー tnakao0123
提出日時 2016-03-04 09:04:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 737 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 84,104 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 14:01:06
合計ジャッジ時間 1,514 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 44.cc: No.44 DPなすごろく - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

typedef long long ll;

/* global variables */

ll dp[MAX_N + 5];

/* subroutines */

/* main */

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

  dp[0] = 1;

  for (int i = 0; i < n; i++) {
    dp[i + 1] += dp[i];
    dp[i + 2] += dp[i];
  }

  printf("%lld\n", dp[n]);
  return 0;
}
0