結果
| 問題 | No.612 Move on grid |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-12 10:48:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 871 bytes |
| 記録 | |
| コンパイル時間 | 502 ms |
| コンパイル使用メモリ | 67,404 KB |
| 最終ジャッジ日時 | 2024-11-14 20:17:47 |
| 合計ジャッジ時間 | 917 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:27: error: ‘powl’ was not declared in this scope
7 | constexpr int mod = int(powl(10, 9)) + 7;
| ^~~~
main.cpp:8:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | int T; scanf("%d", &T);
| ~~~~~^~~~~~~~~~
main.cpp:9:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | int a, b, c, d, e; scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main(void) {
constexpr int mod = int(powl(10, 9)) + 7;
int T; scanf("%d", &T);
int a, b, c, d, e; scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
unordered_map<int, int> dp, ndp;
dp[0] = 1;
for(int t=0; t<T; ++t) {
ndp.clear();
for(auto&& kv : dp) {
int cur = kv.first;
ndp[cur + a] += dp[cur];
ndp[cur + a] %= mod;
ndp[cur - a] += dp[cur];
ndp[cur - a] %= mod;
ndp[cur + b] += dp[cur];
ndp[cur + b] %= mod;
ndp[cur - b] += dp[cur];
ndp[cur - b] %= mod;
ndp[cur + c] += dp[cur];
ndp[cur + c] %= mod;
ndp[cur - c] += dp[cur];
ndp[cur - c] %= mod;
}
dp = ndp;
}
int res = 0;
for(int r=d; r<=e; ++r) {
res += dp[r];
res %= mod;
}
printf("%d\n", res);
return 0;
}