結果
問題 | No.260 世界のなんとか3 |
ユーザー | yui_cute__ |
提出日時 | 2020-06-10 17:23:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,754 bytes |
コンパイル時間 | 1,913 ms |
コンパイル使用メモリ | 177,816 KB |
実行使用メモリ | 13,468 KB |
最終ジャッジ日時 | 2023-09-05 13:15:59 |
合計ジャッジ時間 | 5,148 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | WA | - |
testcase_04 | AC | 134 ms
13,324 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 37 ms
7,608 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 59 ms
10,196 KB |
testcase_13 | WA | - |
testcase_14 | AC | 88 ms
11,852 KB |
testcase_15 | AC | 23 ms
5,168 KB |
testcase_16 | AC | 77 ms
10,204 KB |
testcase_17 | WA | - |
testcase_18 | AC | 60 ms
7,624 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 69 ms
11,056 KB |
testcase_25 | AC | 89 ms
13,320 KB |
testcase_26 | AC | 55 ms
13,400 KB |
testcase_27 | AC | 2 ms
4,380 KB |
testcase_28 | AC | 101 ms
13,320 KB |
testcase_29 | AC | 170 ms
13,320 KB |
ソースコード
#include <bits/stdc++.h> #include <unistd.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7/*998244353*/; const ll INF = 1LL << 60; ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll); // ll fun(const string& s){ vector<vector<vector<vector<ll>>>> dp(s.size() + 1, vector<vector<vector<ll>>>(2, vector<vector<ll>>(2, vector<ll>(24)))); dp[0][0][0][0] = 1; for(int i = 0; i < s.size(); i++){ int d = s[i] - '0'; for(int j = 0; j < 2; j++){//下回ってるか否か for(int k = 0; k < 2; k++){//3が入ってるかどうか for(int mod = 0; mod < 24; mod++){ for(int n = 0; n <= (j ? 9 : d); n++){ dp[i + 1][j || (n < d)][k || (n == 3)][(mod * 10 + n) % 24] = (dp[i + 1][j || (n < d)][k || (n == 3)][(mod * 10 + n) % 24] + dp[i][j][k][mod]) % MOD; } } } } } ll ans = 0; for(int j = 0; j < 2; j++){ for(int mod = 0; mod < 24; mod++){//3が入っていない if(mod % 3 == 0 && (mod % 8)) ans = (ans + dp[s.size()][j][0][mod]) % MOD; } for(int mod = 0; mod < 24; mod++){//いる if(mod % 8) ans = (ans + dp[s.size()][j][1][mod]) % MOD; } } return ans; } int main(){ string a, b; cin >> a >> b; ll ans = fun(b) - fun(a); bool bl = false; int mod = (a[0] - '0'); for(int i = 1; i < a.size(); i++){ bl |= (a[i] == '3'); mod = (mod * 10 + a[i] - '0') % 24; } if(mod % 8 == 0) cout << ans << "\n"; else{ bl |= (mod % 3 == 0); if(bl) cout << ans + 1 << "\n"; else cout << ans << "\n"; } }