結果
問題 | No.260 世界のなんとか3 |
ユーザー | tancahn2380 |
提出日時 | 2017-11-30 21:04:09 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 194 ms / 2,000 ms |
コード長 | 1,994 bytes |
コンパイル時間 | 713 ms |
コンパイル使用メモリ | 87,776 KB |
実行使用メモリ | 18,560 KB |
最終ジャッジ日時 | 2024-05-05 16:25:16 |
合計ジャッジ時間 | 3,768 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 162 ms
18,432 KB |
testcase_04 | AC | 156 ms
18,560 KB |
testcase_05 | AC | 32 ms
6,144 KB |
testcase_06 | AC | 21 ms
5,376 KB |
testcase_07 | AC | 107 ms
13,568 KB |
testcase_08 | AC | 73 ms
10,368 KB |
testcase_09 | AC | 42 ms
7,168 KB |
testcase_10 | AC | 120 ms
14,848 KB |
testcase_11 | AC | 113 ms
14,080 KB |
testcase_12 | AC | 67 ms
9,728 KB |
testcase_13 | AC | 21 ms
5,376 KB |
testcase_14 | AC | 103 ms
13,056 KB |
testcase_15 | AC | 29 ms
5,888 KB |
testcase_16 | AC | 89 ms
11,776 KB |
testcase_17 | AC | 70 ms
10,112 KB |
testcase_18 | AC | 69 ms
9,856 KB |
testcase_19 | AC | 89 ms
11,904 KB |
testcase_20 | AC | 62 ms
9,344 KB |
testcase_21 | AC | 56 ms
8,704 KB |
testcase_22 | AC | 103 ms
12,928 KB |
testcase_23 | AC | 11 ms
5,376 KB |
testcase_24 | AC | 81 ms
10,880 KB |
testcase_25 | AC | 100 ms
11,008 KB |
testcase_26 | AC | 60 ms
10,880 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 154 ms
18,304 KB |
testcase_29 | AC | 194 ms
18,560 KB |
ソースコード
# include <iostream> # include <algorithm> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <utility> # include <stack> # include <queue> # include <list> # include <tuple> using namespace std; using LL = long long; using ULL = unsigned long long; constexpr int INF = 2000000000; constexpr int HINF = INF / 2; constexpr double DINF = 100000000000000000.0; constexpr long long LINF = 9223372036854775807; constexpr long long HLINF = 4500000000000000000; const double PI = acos(-1); int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(x) (x).begin(),(x).end() #define UNIQ(c) (c).erase(unique(ALL((c))), end((c))) #define mp make_pair #define eb emplace_back //typedef pair<LL, LL> P; //typedef pair<P, P> PP; LL dp[101010][2][2][3][8];//keta,less,has3,mod3,mod8 LL dp2[101010][2][2][3][8]; string a; int n; const LL MOD = 1e9 + 7; int main() { cin >> a; for (int c = a.size() - 1; c >= 0; c--) { if (a[c] != '0') { a[c]--; break; } else { a[c] = '9'; } } n = a.length(); dp[0][0][0][0][0] = 1; REP(i, n)REP(j, 2)REP(k, 2)REP(l, 3)REP(m, 8) { int lim = (j ? 9 : a[i] - '0'); REP(d, lim + 1) { (dp[i + 1][j || d < lim][k || d == 3][(l + d) % 3][(10 * m + d) % 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 || l == 0) && m != 0)(ans += dp[n][j][k][l][m]) %= MOD; string b; cin >> b; n = b.length(); dp2[0][0][0][0][0] = 1; REP(i, n)REP(j, 2)REP(k, 2)REP(l, 3)REP(m, 8) { int lim = (j ? 9 : b[i] - '0'); REP(d, lim + 1) { (dp2[i + 1][j || d < lim][k || d == 3][(l + d) % 3][(10 * m + d) % 8] += dp2[i][j][k][l][m]) %= MOD; } } LL ans2 = 0; REP(j, 2)REP(k, 2)REP(l, 3)REP(m, 8)if ((k || l == 0) && m != 0)(ans2 += dp2[n][j][k][l][m]) %= MOD; cout << (ans2 - ans + MOD) % MOD << endl; //system("pause"); }