結果
問題 | No.260 世界のなんとか3 |
ユーザー |
![]() |
提出日時 | 2017-09-11 01:18:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,928 bytes |
コンパイル時間 | 856 ms |
コンパイル使用メモリ | 93,024 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-07 12:55:23 |
合計ジャッジ時間 | 3,923 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 14 |
ソースコード
#include<iostream> #include<algorithm> #include<functional> #include<string> #include<vector> #include<map> #include<set> #include<tuple> #include<stack> #include<queue> #include<deque> #include<sstream> #include<stdio.h> #include<math.h> #include<stdlib.h> #include<bitset> #include<time.h> #include<cstdlib> #include<cassert> #define ll long long #define fi first #define se second #define lengthof(x) (sizeof(x) / sizeof(*(x))) //fill((int*)d, (int*)(d + lengthof(d)), -1); using namespace std; string a,b; const ll MOD=(ll)1e9+7; ll dp[10010][2][2][3][8]; inline ll solve(string s,bool less){ int n=(int)s.length(); dp[0][0][0][0][0]=1; for(int i=0;i<n;i++){ for(int j=0;j<2;j++){ for(int k=0;k<2;k++){ for(int l=0;l<3;l++){ for(int m=0;m<8;m++){ int lim=j?9:s[i]-'0'; for(int d=0;d<lim+1;d++){ (dp[i+1][j || d<lim][k || d==3][(l*10+d)%3][(m*10+d)%8]+=dp[i][j][k][l][m])%=MOD; } } } } } } ll res=0; for(int i=0;i<2;i++){ for(int j=0;j<3;j++){ for(int k=1;k<8;k++){ if(!less && i==0)continue; (res+=dp[n][i][1][j][k])%=MOD; } } } for(int i=0;i<2;i++){ for(int j=1;j<8;j++){ if(!less && i==0)continue; (res+=dp[n][i][0][0][j])%=MOD; } } return res; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<<fixed; #ifdef LOCAL_DEFINE freopen("in", "r", stdin); freopen("out","w",stdout); #endif cin>>a>>b; ll ans=solve(b,1); for(int i=0;i<(int)a.length()+5;i++){ for(int j=0;j<2;j++)for(int k=0;k<2;k++)for(int l=0;l<3;l++)for(int m=0;m<8;m++)dp[i][j][k][l][m]=0; } //cout<<ans<<"\n"; ll ansa=solve(a,0); //cout<<ansa<<"\n"; cout<<ans-ansa<<"\n"; #ifdef LOCAL_DEFINE cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; }