結果

問題 No.260 世界のなんとか3
ユーザー mkawa2mkawa2
提出日時 2023-01-13 00:17:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,791 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 8,652 KB
最終ジャッジ日時 2023-08-25 04:16:08
合計ジャッジ時間 36,845 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,164 KB
testcase_01 AC 16 ms
8,044 KB
testcase_02 AC 17 ms
8,096 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 502 ms
8,228 KB
testcase_06 AC 336 ms
8,116 KB
testcase_07 AC 1,761 ms
8,552 KB
testcase_08 AC 1,220 ms
8,404 KB
testcase_09 AC 672 ms
8,184 KB
testcase_10 AC 1,977 ms
8,616 KB
testcase_11 AC 1,851 ms
8,520 KB
testcase_12 AC 1,107 ms
8,428 KB
testcase_13 AC 318 ms
8,048 KB
testcase_14 AC 1,681 ms
8,596 KB
testcase_15 AC 448 ms
8,028 KB
testcase_16 AC 1,499 ms
8,424 KB
testcase_17 AC 1,163 ms
8,544 KB
testcase_18 AC 1,112 ms
8,228 KB
testcase_19 AC 1,471 ms
8,392 KB
testcase_20 AC 1,047 ms
8,356 KB
testcase_21 AC 929 ms
8,504 KB
testcase_22 AC 1,678 ms
8,456 KB
testcase_23 AC 167 ms
8,216 KB
testcase_24 AC 1,298 ms
8,416 KB
testcase_25 AC 1,314 ms
8,448 KB
testcase_26 AC 1,333 ms
8,416 KB
testcase_27 AC 16 ms
8,088 KB
testcase_28 TLE -
testcase_29 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

def dodp(aa, eq):
    dp = [[0]*24, [0]*24]
    s = t = 0
    for i, a in enumerate(aa):
        ndp = [[0]*24, [0]*24]
        for f in range(2):
            for j in range(24):
                pre = dp[f][j]
                if pre == 0: continue
                for d in range(10):
                    nf = f | (d == 3)
                    nj = (j*10+d)%24
                    ndp[nf][nj] += pre
                    ndp[nf][nj] %= md
        for d in range(i == 0, a):
            nf = t | (d == 3)
            nj = (s*10+d)%24
            ndp[nf][nj] += 1
        if i:
            for d in range(1, 10):
                ndp[d == 3][d] += 1
        if a == 3: t = 1
        s = (s*10+a)%24
        dp = ndp

    res = 0
    for j in range(3, 24, 3):
        res += dp[0][j]
        res %= md
    for j in range(24):
        if j%8 == 0: continue
        res += dp[1][j]
        res %= md
    if eq and s%8 and (t or s%3 == 0): res += 1
    return res

aa,bb = SI().split()
aa=list(map(int,aa))
bb=list(map(int,bb))

ans = dodp(bb, 1)-dodp(aa, 0)
print(ans%md)
0