結果
問題 | No.260 世界のなんとか3 |
ユーザー |
![]() |
提出日時 | 2016-03-01 22:40:46 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,188 bytes |
コンパイル時間 | 1,514 ms |
コンパイル使用メモリ | 161,432 KB |
実行使用メモリ | 11,280 KB |
最終ジャッジ日時 | 2024-09-24 13:16:10 |
合計ジャッジ時間 | 6,049 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++) #define REP(i,e) FOR(i,0,e) #define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--) #define RREP(i,e) RFOR(i,0,e) #define all(o) (o).begin(), (o).end() #define psb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) typedef long long ll; typedef pair<int, int> PII; typedef priority_queue<int> PQI; typedef priority_queue<PII> PQII; const double EPS = 1e-10; const int N = 10000; const int modi = 1e9; ll mod = (ll)modi + 7; ll dp[N+5][2][3][2][8]; ll calc(string x, int less) { int n = (int)x.size(); memset(dp, 0, sizeof(dp)); dp[0][0][0][0][0] = 1; REP(i,n) REP(j,2) REP(k,3) REP(l,2) REP(m,8) { int lim = j ? 9 : x[i]-'0'; REP(d,lim+1) dp[i+1][j || d<lim][(k+d)%3][l || d==3][(m*10+d)%8] = (dp[i+1][j || d<lim][(k+d)%3][l || d==3][(m*10+d)%8] + dp[i][j][k][l][m]) % mod; } ll res = 0; REP(k,3) REP(j,2) REP(l,2) REP(m,8) { if (less && !j) continue; if ((!k || l) && m) res = (res + dp[n][j][k][l][m]) % mod; } return res; } int main() { string a, b; cin >> a >> b; printf("%lld\n", calc(b,0)-calc(a,1)); return 0; }