結果

問題 No.44 DPなすごろく
ユーザー hiromi-mi
提出日時 2018-12-31 11:55:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 657 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 62,276 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 01:55:27
合計ジャッジ時間 1,246 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>
#include <assert.h>

using namespace std;

typedef long long ll;


#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

int N;
ll dp[110][60];

int main() {
   cin >> N;
   dp[0][0] = 1;
   ll ans = 0;
   rep(i, N+1) {
      dp[1][i+1] = dp[0][i];
      for (int j=N;j>=2;j--) {
         dp[j][i+1] = dp[j-2][i] + dp[j-1][i];
      }
      ans += dp[N][i];
   }
   cout << ans << endl;
}

0