結果

問題 No.44 DPなすごろく
ユーザー shossiissohs
提出日時 2018-01-10 18:32:13
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 417 bytes
コンパイル時間 2,385 ms
コンパイル使用メモリ 157,904 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 15:42:45
合計ジャッジ時間 1,891 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll dp[105][105];
int main() {
  int n;

  cin >> n;
  dp[0][0] = 1;

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

  ll ans = 0;
  for(int i = 0; i <= n; i++) ans += dp[i][n];

  cout << ans << endl;
}
0