結果

問題 No.44 DPなすごろく
ユーザー DialBird
提出日時 2017-02-08 17:57:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 560 bytes
コンパイル時間 2,439 ms
コンパイル使用メモリ 58,488 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 16:49:33
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

int N;
long long dp[100][100];

long long calc(int x, int y) {
  if (dp[x][y] != -1) return dp[x][y];

  int total = x + 2*y;

  if (total > N) return 0;
  if (total == N) return 1;

  return dp[x][y] = calc(x+1, y) + calc(x, y+1);
}

int main(){
  cin >> N;

  REP(i,0,100){
    REP(j,0,100){
      dp[i][j] = -1;
    }
  }

  cout << calc(0,0) << endl;
}
0