結果
問題 | No.260 世界のなんとか3 |
ユーザー | pione |
提出日時 | 2020-05-25 05:47:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,525 bytes |
コンパイル時間 | 1,456 ms |
コンパイル使用メモリ | 172,168 KB |
実行使用メモリ | 11,064 KB |
最終ジャッジ日時 | 2024-10-13 01:50:18 |
合計ジャッジ時間 | 3,401 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
10,880 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 76 ms
10,880 KB |
testcase_04 | AC | 76 ms
11,008 KB |
testcase_05 | WA | - |
testcase_06 | AC | 14 ms
10,812 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 52 ms
10,888 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 47 ms
11,008 KB |
testcase_26 | AC | 41 ms
10,940 KB |
testcase_27 | AC | 6 ms
10,824 KB |
testcase_28 | AC | 70 ms
10,880 KB |
testcase_29 | WA | - |
ソースコード
#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; ll nj=j,nk=k,nl,nm; if(nxt<now) nj=1; if(nxt==3) nk=1; nl=(l*10+nxt)%3; nm=(m*10+nxt)%8; (dp[i+1][nj][nk][nl][nm]+=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); ll ans=(f(b)-f(a)+MOD)%MOD; cout<<ans<<endl; }