結果

問題 No.260 世界のなんとか3
ユーザー motimoti
提出日時 2015-12-08 22:39:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,539 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 98,856 KB
実行使用メモリ 12,252 KB
最終ジャッジ日時 2023-10-12 22:11:13
合計ジャッジ時間 3,781 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
10,968 KB
testcase_01 AC 6 ms
10,804 KB
testcase_02 AC 7 ms
10,848 KB
testcase_03 WA -
testcase_04 AC 97 ms
12,032 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 30 ms
11,600 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 45 ms
11,636 KB
testcase_13 WA -
testcase_14 AC 64 ms
11,892 KB
testcase_15 AC 21 ms
11,240 KB
testcase_16 AC 57 ms
11,632 KB
testcase_17 WA -
testcase_18 AC 44 ms
11,340 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 51 ms
11,792 KB
testcase_25 AC 53 ms
11,992 KB
testcase_26 AC 51 ms
12,252 KB
testcase_27 AC 6 ms
10,908 KB
testcase_28 AC 94 ms
12,120 KB
testcase_29 AC 96 ms
11,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define minimize(a, x) a = std::min(a, x)
#define maximize(a, x) a = std::max(a, x)

typedef long long ll;
int const inf = 1<<29;

int P;
int nA, nB;

int const MOD = 1e9+7;

ll dp[10010][2][24][2];
int ssize;

string S;
bool isA;

int func(int index = 0, bool giri = true, int mod24 = 0, bool used3 = false) {
  if(index >= ssize) {
    if(giri && isA) { return 0; }
    return ((mod24 % 3 == 0) || used3) && (mod24 % 8);
  }

  auto& ret = dp[index][giri][mod24][used3];

  if(ret + 1) { return ret; }

  ret = 0;

  int digit = S[index] - '0';
  int mx = giri ? digit + 1 : 10;
  rep(i, mx) {
    ret += func(index + 1, giri && (i == digit), (mod24 * 10 + i) % 24, used3 || (i == 3));
    if(ret >= MOD) ret -= MOD;
  }

  return ret;
}

int main() {
  string A, B; cin >> A >> B;
  S = B; ssize = S.size(); isA = false; minus(dp);
  int ans = func();
  S = A; ssize = S.size(); isA = true; minus(dp);
  ans -= func();
  cout << ans << endl;
}
0