結果
問題 | No.260 世界のなんとか3 |
ユーザー | Grun1396 |
提出日時 | 2018-06-01 20:53:46 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,615 bytes |
コンパイル時間 | 450 ms |
コンパイル使用メモリ | 55,428 KB |
実行使用メモリ | 41,560 KB |
最終ジャッジ日時 | 2023-09-12 21:26:17 |
合計ジャッジ時間 | 4,466 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
41,288 KB |
testcase_01 | AC | 20 ms
41,292 KB |
testcase_02 | AC | 21 ms
41,348 KB |
testcase_03 | WA | - |
testcase_04 | AC | 157 ms
41,260 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 56 ms
41,228 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 79 ms
41,292 KB |
testcase_13 | WA | - |
testcase_14 | AC | 109 ms
41,252 KB |
testcase_15 | AC | 44 ms
41,272 KB |
testcase_16 | AC | 98 ms
41,440 KB |
testcase_17 | WA | - |
testcase_18 | AC | 79 ms
41,296 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 88 ms
41,332 KB |
testcase_25 | AC | 109 ms
41,292 KB |
testcase_26 | AC | 70 ms
41,248 KB |
testcase_27 | AC | 21 ms
41,280 KB |
testcase_28 | AC | 118 ms
41,316 KB |
testcase_29 | AC | 196 ms
41,336 KB |
ソースコード
#include <iostream> #include <string> #define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++) #define rep(i,n) reps(i,0,n) using namespace std; typedef long long ll; const int MOD = 1e9+7; int dp[101010][2][2][3][8]; string A,B; int func(string A,bool less){ int n = A.length(); rep(i,101010){ rep(j,2){ rep(k,2){ rep(l,3){ rep(m,8){ dp[i][j][k][l][m] = 0; } } } } } dp[0][0][0][0][0] = 1; rep(i,n){ rep(j,2){ rep(k,2){ rep(l,3){ rep(m,8){ int lim = j ? 9 : A[i] - '0'; rep(d,lim+1){ ( dp[i+1] [j || d < lim] [k || d == 3] [(l+d)%3] [(m*10+d)%8] += dp[i][j][k][l][m]) %= MOD; } } } } } } int ans = 0; int index = 0; if(!less) index = 1; reps(j,index,2){ rep(k,2){ rep(l,3){ rep(m,8){ if( (k || l == 0) && m != 0){ (ans += dp[n][j][k][l][m]) %= MOD; } } } } } return ans; } int main(){ cin >> A >> B; int ans = 0; (ans = func(B,true)-func(A,false)) %= MOD; cout << ans << endl; return 0; }