結果
問題 | No.2017 Mod7 Parade |
ユーザー | milanis48663220 |
提出日時 | 2022-07-22 22:07:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 2,616 bytes |
コンパイル時間 | 1,354 ms |
コンパイル使用メモリ | 127,524 KB |
実行使用メモリ | 50,068 KB |
最終ジャッジ日時 | 2023-09-17 10:14:40 |
合計ジャッジ時間 | 4,117 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 98 ms
39,676 KB |
testcase_04 | AC | 66 ms
27,624 KB |
testcase_05 | AC | 50 ms
21,192 KB |
testcase_06 | AC | 109 ms
43,616 KB |
testcase_07 | AC | 15 ms
8,108 KB |
testcase_08 | AC | 62 ms
26,036 KB |
testcase_09 | AC | 26 ms
11,696 KB |
testcase_10 | AC | 63 ms
26,204 KB |
testcase_11 | AC | 87 ms
35,120 KB |
testcase_12 | AC | 76 ms
31,356 KB |
testcase_13 | AC | 126 ms
50,052 KB |
testcase_14 | AC | 124 ms
49,968 KB |
testcase_15 | AC | 125 ms
49,988 KB |
testcase_16 | AC | 127 ms
50,068 KB |
testcase_17 | AC | 126 ms
49,872 KB |
testcase_18 | AC | 121 ms
50,000 KB |
testcase_19 | AC | 104 ms
49,924 KB |
testcase_20 | AC | 2 ms
4,376 KB |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #include <atcoder/modint> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template<typename T> vector<vector<T>> vec2d(int n, int m, T v){ return vector<vector<T>>(n, vector<T>(m, v)); } template<typename T> vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){ return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v))); } template<typename T> void print_vector(vector<T> v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using mint = atcoder::modint1000000007; ostream& operator<<(ostream& os, const mint& m){ os << m.val(); return os; } mint pow(mint a, ll n) { assert(n >= 0); mint ans = 1; while (n > 0) { if (n&1) ans = ans*a; a = a*a; n >>= 1; } return ans; } ll mod_pow(ll a, ll n, ll mod) { ll ans = 1; while (n > 0) { if (n&1) ans = (ans*a)%mod; a = (a*a)% mod; n >>= 1; } return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int k; cin >> k; vector<int> d(k), l(k); for(int i = 0; i < k; i++){ cin >> d[i] >> l[i]; } auto dp = vec3d(k+1, 6, 7, mint(0)); dp[k][0][0] = 1; vector<int> rem(6); for(int i = 0; i < 6; i++) rem[i] = mod_pow(10, i, 7); for(int i = k-1; i >= 0; i--){ int len = l[i]%6; int cur = ((mod_pow(10, l[i], 7)+6)*4*d[i])%7; for(int j = 0; j < 6; j++){ for(int p = 0; p <= 6; p++){ // 使わない dp[i][j][p] += dp[i+1][j][p]; // 使う int rr = (p+cur*rem[j])%7; dp[i][(j+len)%6][rr] += dp[i+1][j][p]; } } } mint ans = 0; for(int j = 0; j < 6; j++){ for(int k = 0; k < 7; k++){ ans += dp[0][j][k]*k; } } cout << ans << endl; }