結果

問題 No.612 Move on grid
ユーザー pekempey
提出日時 2017-12-12 00:04:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 70,920 KB
実行使用メモリ 83,712 KB
最終ジャッジ日時 2024-11-30 21:13:58
合計ジャッジ時間 3,046 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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