結果
問題 | No.2017 Mod7 Parade |
ユーザー | 沙耶花 |
提出日時 | 2022-07-22 21:41:03 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,230 ms / 2,000 ms |
コード長 | 948 bytes |
コンパイル時間 | 4,468 ms |
コンパイル使用メモリ | 260,304 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-17 09:21:11 |
合計ジャッジ時間 | 17,809 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 866 ms
4,380 KB |
testcase_04 | AC | 577 ms
4,376 KB |
testcase_05 | AC | 428 ms
4,380 KB |
testcase_06 | AC | 957 ms
4,376 KB |
testcase_07 | AC | 119 ms
4,376 KB |
testcase_08 | AC | 544 ms
4,376 KB |
testcase_09 | AC | 206 ms
4,376 KB |
testcase_10 | AC | 548 ms
4,376 KB |
testcase_11 | AC | 759 ms
4,384 KB |
testcase_12 | AC | 667 ms
4,380 KB |
testcase_13 | AC | 1,105 ms
4,376 KB |
testcase_14 | AC | 1,108 ms
4,376 KB |
testcase_15 | AC | 1,106 ms
4,380 KB |
testcase_16 | AC | 1,106 ms
4,376 KB |
testcase_17 | AC | 1,107 ms
4,380 KB |
testcase_18 | AC | 1,230 ms
4,376 KB |
testcase_19 | AC | 88 ms
4,376 KB |
testcase_20 | AC | 1 ms
4,376 KB |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint1000000007; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000 vector<long long> dp(30); long long get(long long N){ long long cur = 0; rep(i,30){ if((N>>i)&1){ long long t = pow_mod(10,1<<i,7); t *= cur; t += dp[i]; cur = t; } } return cur; } int main(){ dp[0] = 1; for(int i=1;i<30;i++){ long long t = pow_mod(10,1<<(i-1),7); t *= dp[i-1]; t += dp[i-1]; t %= 7; dp[i] = t; } int K; cin>>K; vector<mint> dp(7,0); dp[0] = 1; rep(i,K){ long long D,L; cin>>D>>L; vector<mint> ndp(7,0); rep(j,7){ ndp[j] += dp[j]; long long t = j; t *= pow_mod(10,L,7); t %= 7; t += get(L) * D; t %= 7; ndp[t] += dp[j]; } swap(dp,ndp); } mint ans = 0; rep(i,7){ ans += dp[i] * i; } cout<<ans.val()<<endl; return 0; }