結果
問題 | No.260 世界のなんとか3 |
ユーザー | tancahn2380 |
提出日時 | 2017-11-30 21:01:46 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,965 bytes |
コンパイル時間 | 752 ms |
コンパイル使用メモリ | 87,576 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-05-05 16:24:39 |
合計ジャッジ時間 | 3,637 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | AC | 128 ms
10,880 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 35 ms
5,376 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 56 ms
6,656 KB |
testcase_13 | WA | - |
testcase_14 | AC | 85 ms
8,320 KB |
testcase_15 | AC | 23 ms
5,376 KB |
testcase_16 | AC | 72 ms
7,552 KB |
testcase_17 | WA | - |
testcase_18 | AC | 57 ms
6,528 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 65 ms
7,168 KB |
testcase_25 | AC | 85 ms
7,168 KB |
testcase_26 | AC | 49 ms
7,296 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 130 ms
10,880 KB |
testcase_29 | AC | 163 ms
10,880 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; int dp[101010][2][2][3][8];//keta,less,has3,mod3,mod8 int dp2[101010][2][2][3][8]; string a; int n; const int MOD = 1e9 + 7; int main() { cin >> a; for (int b = a.size() - 1; b >= 0; b--) { if (a[b] != '0') { a[b]--; break; } else { a[b] = '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; } } int 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; } } int 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 << endl; }