結果
問題 | No.315 世界のなんとか3.5 |
ユーザー | muriro4 |
提出日時 | 2018-12-14 22:20:40 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,464 bytes |
コンパイル時間 | 1,580 ms |
コンパイル使用メモリ | 165,204 KB |
実行使用メモリ | 160,928 KB |
最終ジャッジ日時 | 2024-09-25 05:22:28 |
合計ジャッジ時間 | 39,543 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 110 ms
160,412 KB |
testcase_01 | AC | 109 ms
153,472 KB |
testcase_02 | AC | 112 ms
153,344 KB |
testcase_03 | AC | 109 ms
153,472 KB |
testcase_04 | AC | 110 ms
153,344 KB |
testcase_05 | AC | 109 ms
153,344 KB |
testcase_06 | AC | 109 ms
153,472 KB |
testcase_07 | AC | 109 ms
153,344 KB |
testcase_08 | AC | 110 ms
153,472 KB |
testcase_09 | AC | 109 ms
153,344 KB |
testcase_10 | AC | 111 ms
153,472 KB |
testcase_11 | AC | 110 ms
153,344 KB |
testcase_12 | AC | 742 ms
153,600 KB |
testcase_13 | AC | 738 ms
153,728 KB |
testcase_14 | AC | 1,353 ms
153,664 KB |
testcase_15 | AC | 1,366 ms
153,600 KB |
testcase_16 | AC | 1,340 ms
153,540 KB |
testcase_17 | AC | 1,339 ms
153,664 KB |
testcase_18 | AC | 737 ms
153,728 KB |
testcase_19 | AC | 729 ms
153,600 KB |
testcase_20 | AC | 732 ms
153,472 KB |
testcase_21 | AC | 733 ms
153,600 KB |
testcase_22 | AC | 1,342 ms
153,664 KB |
testcase_23 | AC | 1,342 ms
153,668 KB |
testcase_24 | AC | 1,339 ms
153,472 KB |
testcase_25 | AC | 1,326 ms
153,540 KB |
testcase_26 | AC | 1,332 ms
153,668 KB |
testcase_27 | AC | 1,352 ms
153,600 KB |
testcase_28 | AC | 1,326 ms
153,536 KB |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | TLE | - |
testcase_33 | AC | 1,362 ms
153,728 KB |
testcase_34 | WA | - |
testcase_35 | TLE | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++) typedef long long llong; char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; char moji3[10]={'0','1','2','3','4','5','6','7','8','9'}; #define Sort(a) sort(a.begin(),a.end()); #define Reverse(a) reverse(a.begin(),a.end()); #define print(a) cout << a << endl; #define MOD llong(1e9 +7) #define MAX 200005 int main(){ llong ans[2]; string S[2]; string p; cin >> S[0] >> S[1] >> p; int p_keta = p.length(); REP(iiii,2){ string s; s = S[iiii]; int n = s.length(); int dp[MAX][2][2][3][8][2]; if(iiii == 1) REP(i,n+1) REP(j,2) REP(k,2) REP(ii,3) REP(jj,8) REP(kk,2) dp[i][j][k][ii][jj][kk] = 0; dp[0][0][0][0][0][0] = 1; FOR(i,1,n+1){ REP(iii,2){ if(iii == 1 and i < n + 1 - p_keta) continue; REP(j,2){ REP(ii,2){ REP(jj,3){ REP(kk,8){ int lim = j ? 9 : s[i-1] - '0'; REP(k,lim +1){ dp[i][j or k < lim][ii or k == 3][(jj + k) % 3][(kk * 10 + k)%8][(k == 0 and (iii or (n + 2 - p_keta == i and kk ==0))) or (p_keta == 1 and (10*kk+k)%8 == 0 and i == n)] += dp[i-1][j][ii][jj][kk][iii]; dp[i][j or k < lim][ii or k == 3][(jj+k) % 3][(kk * 10 + k)%8][(k == 0 and (iii or (n + 2 - p_keta == i and kk ==0))) or (p_keta == 1 and (10*kk+k)%8 == 0 and i == n)] %=MOD; } } } } } } } ans[iiii] = 0; REP(i,2){ if(iiii == 0 and i == 0) continue; REP(j,2) REP(k,3) REP(ii,8){ if(j== 0 and k != 0) continue; ans[iiii] += dp[n][i][j][k][ii][0]; ans[iiii] %=MOD; } } } cout << (MOD + ans[1] - ans[0]) % MOD << endl; }