結果

問題 No.260 世界のなんとか3
ユーザー gabriel55_gabriel55_
提出日時 2023-01-15 16:47:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 2,233 bytes
コンパイル時間 4,524 ms
コンパイル使用メモリ 271,080 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2023-08-28 09:02:13
合計ジャッジ時間 8,434 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 172 ms
13,904 KB
testcase_04 AC 173 ms
13,956 KB
testcase_05 AC 35 ms
6,988 KB
testcase_06 AC 23 ms
6,092 KB
testcase_07 AC 117 ms
12,532 KB
testcase_08 AC 84 ms
12,536 KB
testcase_09 AC 46 ms
7,804 KB
testcase_10 AC 133 ms
11,572 KB
testcase_11 AC 124 ms
13,140 KB
testcase_12 AC 77 ms
10,744 KB
testcase_13 AC 21 ms
4,920 KB
testcase_14 AC 112 ms
12,548 KB
testcase_15 AC 29 ms
5,416 KB
testcase_16 AC 99 ms
10,836 KB
testcase_17 AC 79 ms
8,672 KB
testcase_18 AC 76 ms
7,952 KB
testcase_19 AC 99 ms
12,348 KB
testcase_20 AC 69 ms
8,972 KB
testcase_21 AC 62 ms
9,424 KB
testcase_22 AC 111 ms
10,888 KB
testcase_23 AC 12 ms
4,376 KB
testcase_24 AC 89 ms
11,524 KB
testcase_25 AC 109 ms
14,072 KB
testcase_26 AC 66 ms
14,080 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 133 ms
13,908 KB
testcase_29 AC 220 ms
13,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#if !__INCLUDE_LEVEL__
#include __FILE__

using mint = modint1000000007;

int main(void){
   mint ans = 0;
   rep(x,2){
      string s;
      cin >> s;
      ll n = s.length();
      vector dp(n+1, vector<vector<vector<vector<mint>>>>(2, vector<vector<vector<mint>>>(2, vector<vector<mint>>(3, vector<mint>(8, 0)))));
      dp[0][0][0][0][0] = 1;
      rep(i,n) rep(j,2) rep(k,2) rep(l,3) rep(m,8) {
         ll lim = j ? 9 : s[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];
      }

      rep(j,2) rep(k,2) rep(l,3) m_99(m,1,8) {
         if(!x && !j) continue;
         if(k || !l) {
            if(!x) ans -= dp[n][j][k][l][m];
            else ans += dp[n][j][k][l][m];
         }
      }
   }
   cout << ans.val() << '\n';
}

/*---------------------------------------------------------------------------------------------------
      ○______
       ||      |
       ||   ●   |
       ||      |
        || ̄ ̄ ̄ ̄ ̄
       ||  君が代は
   ∧__,,∧||  千代に八千代に
  ( `・ω・||    さざれ石の巌となりて
   ヽ  つ0     こけのむすまで
   し―-J
---------------------------------------------------------------------------------------------------*/

#else
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ldb = long double;
using P = pair<ll, ll>;
#define fi first
#define se second
#define m_99(i,a,b) for (ll i = a, i##_range = (b); i < i##_range; i++)
#define rep(i,a) m_99(i,0,a)
template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; }
template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; }
#ifdef LOCAL
#include <debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif
struct initialise { initialise() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }__INI__;
const ll inf = 1LL << 60;
const ll dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
#endif
0