結果
問題 | No.260 世界のなんとか3 |
ユーザー | pione |
提出日時 | 2020-05-25 05:32:05 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,517 bytes |
コンパイル時間 | 1,372 ms |
コンパイル使用メモリ | 170,556 KB |
実行使用メモリ | 10,820 KB |
最終ジャッジ日時 | 2024-10-13 00:32:11 |
合計ジャッジ時間 | 7,819 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
コンパイルメッセージ
main.cpp: In function 'll f(std::string)': main.cpp:67:1: warning: no return statement in function returning non-void [-Wreturn-type] 67 | } | ^
ソースコード
#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; } } 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; ans%=MOD; cout<<ans<<endl; }