結果
問題 | No.260 世界のなんとか3 |
ユーザー | pione |
提出日時 | 2020-05-25 05:47:12 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 169 ms / 2,000 ms |
コード長 | 2,473 bytes |
コンパイル時間 | 1,473 ms |
コンパイル使用メモリ | 170,796 KB |
実行使用メモリ | 11,088 KB |
最終ジャッジ日時 | 2024-10-13 01:48:44 |
合計ジャッジ時間 | 4,260 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
10,880 KB |
testcase_01 | AC | 5 ms
10,972 KB |
testcase_02 | AC | 5 ms
10,816 KB |
testcase_03 | AC | 135 ms
10,868 KB |
testcase_04 | AC | 135 ms
10,992 KB |
testcase_05 | AC | 29 ms
10,880 KB |
testcase_06 | AC | 21 ms
11,024 KB |
testcase_07 | AC | 92 ms
11,024 KB |
testcase_08 | AC | 66 ms
10,852 KB |
testcase_09 | AC | 38 ms
10,980 KB |
testcase_10 | AC | 104 ms
10,924 KB |
testcase_11 | AC | 100 ms
10,892 KB |
testcase_12 | AC | 61 ms
10,824 KB |
testcase_13 | AC | 20 ms
10,876 KB |
testcase_14 | AC | 89 ms
10,936 KB |
testcase_15 | AC | 26 ms
10,856 KB |
testcase_16 | AC | 77 ms
10,868 KB |
testcase_17 | AC | 59 ms
10,832 KB |
testcase_18 | AC | 58 ms
10,852 KB |
testcase_19 | AC | 77 ms
10,920 KB |
testcase_20 | AC | 56 ms
10,828 KB |
testcase_21 | AC | 48 ms
10,876 KB |
testcase_22 | AC | 90 ms
10,948 KB |
testcase_23 | AC | 12 ms
10,884 KB |
testcase_24 | AC | 70 ms
10,904 KB |
testcase_25 | AC | 88 ms
10,892 KB |
testcase_26 | AC | 54 ms
11,044 KB |
testcase_27 | AC | 5 ms
10,820 KB |
testcase_28 | AC | 137 ms
11,088 KB |
testcase_29 | AC | 169 ms
10,924 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--) #define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i) #define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i) #define SORT(v, n) sort(v, v + n); #define REVERSE(v, n) reverse(v, v+n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cout(d) cout<<d<<endl; #define coutd(d) cout<<std::setprecision(10)<<d<<endl; #define cinline(n) getline(cin,n); #define replace_all(s, b, a) replace(s.begin(),s.end(), b, a); #define PI (acos(-1)) #define FILL(v, n, x) fill(v, v + n, x); #define sz(x) long long(x.size()) using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vs = vector<string>; using vpll = vector<pair<ll, ll>>; using tll = tuple<ll,ll,ll>; using vtll = vector<tuple<ll,ll,ll>>; using vb = vector<bool>; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e9; const ll MOD = 1e9+7; const ll LINF = 1e18; ll dp[10005][2][2][3][8]; // pos, isLess, has3, mod3, mod8 ll f(string s){ ll n=s.size(); memset(dp,0,sizeof(dp)); dp[0][0][0][0][0]=1; rep(i,n) rep(j,2) rep(k,2) rep(l,3) rep(m,8){ ll now=s[i]-'0'; rep(nxt,10){ if(nxt>now && j==0) continue; (dp[i+1][j||(nxt<now)][k||(nxt==3)][(l*10+nxt)%3][(m*10+nxt)%8]+=dp[i][j][k][l][m])%=MOD; } } ll ans=0; rep(j,2) rep(k,2) rep(l,3) rep(m,8){ if((k==1||l==0)&&m!=0) (ans+=dp[n][j][k][l][m])%=MOD; } return ans; } string decdec(string A) { reverse(A.begin(),A.end()); for(auto &r: A) { if(r!='0') { r--; break; } r='9'; } if(A.back()=='0') A.resize(A.size()-1); reverse(A.begin(),A.end()); return A; } signed main() { cin.tie( 0 ); ios::sync_with_stdio( false ); string a,b; cin>>a>>b; a=decdec(a); // cout<<a<<endl; ll ans=(f(b)-f(a)+MOD)%MOD; cout<<ans<<endl; }