結果
問題 | No.612 Move on grid |
ユーザー |
![]() |
提出日時 | 2018-01-05 20:54:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,500 ms |
コード長 | 979 bytes |
コンパイル時間 | 868 ms |
コンパイル使用メモリ | 78,644 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 06:11:03 |
合計ジャッジ時間 | 1,902 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <string> #include <climits> #include <functional> #include "math.h" using namespace std; typedef long long ll; int main() { ll mod = 1000000007; int T, a, b, c, d, e; cin >> T >> a >> b >> c >> d >> e; a = abs(a); b = abs(b); c = abs(c); if (b < c) swap(b, c); if (a < b) swap(a, b); ll nums[20002] = {0}; nums[10001] = 1; int l = 0; int r = 1; for (int i = 0; i < T; ++i) { l -= a; r += a; ll cur_nums[20002] = {0}; for (int j = 10001 + l; j < 10001 + r; ++j) { if (nums[j] != 0) { cur_nums[j + a] += nums[j] % mod; cur_nums[j - a] += nums[j] % mod; cur_nums[j + b] += nums[j] % mod; cur_nums[j - b] += nums[j] % mod; cur_nums[j + c] += nums[j] % mod; cur_nums[j - c] += nums[j] % mod; } } swap(nums, cur_nums); } ll ans = 0; for (int i = 10001 + d; i < 10002 + e; ++i) { ans += nums[i] % mod; } cout << ans % mod << endl; }