結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,320 KB
testcase_01 AC 16 ms
8,272 KB
testcase_02 AC 17 ms
8,272 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 493 ms
8,280 KB
testcase_06 AC 337 ms
8,364 KB
testcase_07 AC 1,771 ms
8,428 KB
testcase_08 AC 1,231 ms
8,324 KB
testcase_09 AC 677 ms
8,184 KB
testcase_10 AC 1,999 ms
8,528 KB
testcase_11 AC 1,894 ms
8,380 KB
testcase_12 AC 1,140 ms
8,152 KB
testcase_13 AC 325 ms
8,228 KB
testcase_14 AC 1,789 ms
8,484 KB
testcase_15 AC 454 ms
8,180 KB
testcase_16 AC 1,491 ms
8,352 KB
testcase_17 AC 1,176 ms
7,980 KB
testcase_18 AC 1,133 ms
8,068 KB
testcase_19 AC 1,483 ms
8,416 KB
testcase_20 AC 1,032 ms
8,128 KB
testcase_21 AC 921 ms
8,296 KB
testcase_22 AC 1,681 ms
8,408 KB
testcase_23 AC 165 ms
8,364 KB
testcase_24 AC 1,304 ms
8,340 KB
testcase_25 AC 1,316 ms
8,332 KB
testcase_26 AC 1,313 ms
8,396 KB
testcase_27 AC 16 ms
8,224 KB
testcase_28 TLE -
testcase_29 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def SI(): return sys.stdin.readline().rstrip()

md = 10**9+7

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=[[],[]]
i=0
for c in SI():
    if c==" ":
        i+=1
    else:
        aa[i].append(int(c))

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