結果
| 問題 |
No.260 世界のなんとか3
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-01 20:50:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,593 bytes |
| コンパイル時間 | 486 ms |
| コンパイル使用メモリ | 58,440 KB |
| 実行使用メモリ | 41,536 KB |
| 最終ジャッジ日時 | 2024-06-30 08:56:59 |
| 合計ジャッジ時間 | 3,753 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 14 |
ソースコード
#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 = func(B,true)-func(A,false);
cout << ans << endl;
return 0;
}