結果
| 問題 | No.612 Move on grid |
| コンテスト | |
| ユーザー |
tsutaj
|
| 提出日時 | 2017-11-30 00:23:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 2,500 ms |
| コード長 | 760 bytes |
| 記録 | |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 30,216 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-12-05 13:12:29 |
| 合計ジャッジ時間 | 2,941 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d%d%d%d%d%d", &T, &a, &b, &c, &d, &e);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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