結果
| 問題 |
No.612 Move on grid
|
| コンテスト | |
| ユーザー |
tsutaj
|
| 提出日時 | 2017-11-30 00:23:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 169 ms / 2,500 ms |
| コード長 | 760 bytes |
| コンパイル時間 | 304 ms |
| コンパイル使用メモリ | 33,536 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-18 00:42:31 |
| 合計ジャッジ時間 | 2,999 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include <cstdio>
#include <cstring>
const int MOD = 1000000007;
const int SEG = 20000;
int T, a, b, c, d, e;
int dp[2][SEG + 10];
int main() {
scanf("%d%d%d%d%d%d", &T, &a, &b, &c, &d, &e);
dp[0][SEG / 2] = 1;
for(int i=0; i<T; i++) {
int mo = i % 2;
for(int j=0; j<=SEG; j++) {
int array[] = {-a, a, -b, b, -c, c};
for(int k=0; k<6; k++) {
int npos = j + array[k];
if(npos < 0 || npos > SEG) continue;
(dp[mo^1][npos] += dp[mo][j]) %= MOD;
}
}
memset(dp[mo], 0, sizeof(dp[mo]));
}
int ans = 0;
for(int i=d+SEG/2; i<=e+SEG/2; i++) {
(ans += dp[T%2][i]) %= MOD;
}
printf("%d\n", ans);
return 0;
}
tsutaj