結果
| 問題 | No.612 Move on grid |
| コンテスト | |
| ユーザー |
りあん
|
| 提出日時 | 2017-11-23 16:54:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,500 ms |
| コード長 | 870 bytes |
| 記録 | |
| コンパイル時間 | 1,561 ms |
| コンパイル使用メモリ | 165,832 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-12-05 13:12:19 |
| 合計ジャッジ時間 | 3,207 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;
int main() {
int t, a, b, c, d, e;
cin >> t >> a >> b >> c >> d >> e;
const int m = 20020, s = 10010;
vector<int> dp(m, 0);
dp[s] = 1;
for (int i = 0; i < t; ++i) {
vector<int> nex(m, 0);
for (int j = 0; j < m; ++j) {
if (dp[j] > 0) {
nex[j + a] = (nex[j + a] + dp[j]) % M;
nex[j - a] = (nex[j - a] + dp[j]) % M;
nex[j + b] = (nex[j + b] + dp[j]) % M;
nex[j - b] = (nex[j - b] + dp[j]) % M;
nex[j + c] = (nex[j + c] + dp[j]) % M;
nex[j - c] = (nex[j - c] + dp[j]) % M;
}
}
dp = nex;
}
int ans = 0;
for (int i = s + d; i <= s + e; ++i)
ans = (ans + dp[i]) % M;
cout << ans << "\n";
return 0;
}
りあん