結果

問題 No.612 Move on grid
ユーザー pekempeypekempey
提出日時 2017-12-12 00:04:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 69,900 KB
実行使用メモリ 83,612 KB
最終ジャッジ日時 2023-08-20 17:38:10
合計ジャッジ時間 3,386 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 32 ms
22,580 KB
testcase_04 WA -
testcase_05 AC 133 ms
83,464 KB
testcase_06 AC 129 ms
83,412 KB
testcase_07 WA -
testcase_08 AC 120 ms
83,464 KB
testcase_09 AC 117 ms
83,612 KB
testcase_10 AC 80 ms
53,320 KB
testcase_11 AC 40 ms
27,056 KB
testcase_12 AC 91 ms
62,972 KB
testcase_13 AC 55 ms
36,804 KB
testcase_14 AC 118 ms
72,744 KB
testcase_15 AC 36 ms
28,752 KB
testcase_16 AC 111 ms
82,636 KB
testcase_17 AC 51 ms
38,264 KB
testcase_18 AC 100 ms
74,132 KB
testcase_19 AC 79 ms
58,084 KB
testcase_20 AC 110 ms
78,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

// 20 * 500 * 2

const long long mod = 1e9 + 7;

long long dp[501][22020];

void to(long long &x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
}

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

  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;

  dp[0][10000] = 1;

  for (int i = 0; i < n; i++) {
    for (int j = 50; j < 20000; j++) {
      to(dp[i + 1][j + a], dp[i][j]);
      to(dp[i + 1][j - a], dp[i][j]);
      to(dp[i + 1][j + b], dp[i][j]);
      to(dp[i + 1][j - b], dp[i][j]);
      to(dp[i + 1][j + c], dp[i][j]);
      to(dp[i + 1][j - c], dp[i][j]);
    }
  }

  long long ans = 0;
  for (int i = 10000 + d; i <= 10000 + e; i++) {
    to(ans, dp[n][i]);
  }
  cout << ans << endl;
}
0