結果

問題 No.260 世界のなんとか3
ユーザー terasaterasa
提出日時 2022-11-04 22:08:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,634 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 12,624 KB
最終ジャッジ日時 2023-09-26 00:35:19
合計ジャッジ時間 34,655 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,072 KB
testcase_01 AC 18 ms
8,040 KB
testcase_02 AC 19 ms
8,072 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 1,010 ms
8,044 KB
testcase_06 AC 670 ms
8,208 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 AC 1,391 ms
8,024 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 647 ms
8,060 KB
testcase_14 TLE -
testcase_15 AC 889 ms
8,036 KB
testcase_16 RE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 AC 1,918 ms
8,032 KB
testcase_22 RE -
testcase_23 AC 339 ms
8,204 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 AC 19 ms
8,024 KB
testcase_28 TLE -
testcase_29 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def readints(): return map(int, input().split())
def readlist(): return list(readints())
def readstr(): return input().rstrip()


A, B = input().split()
mod = 10 ** 9 + 7


def solve(N):
    dp = [[[0, 0] for _ in range(2)] for _ in range(24)]
    dp[0][0][0] = 1
    for i in range(len(N)):
        ndp = [[[0, 0] for _ in range(2)] for _ in range(24)]
        for j in range(24):
            for k in range(10):
                n = (j * 10 + k) % 24
                if k == 3:
                    ndp[n][1][1] += dp[j][1][1] + dp[j][0][1]
                else:
                    ndp[n][1][1] += dp[j][1][1]
                    ndp[n][0][1] += dp[j][0][1]

                if k < int(N[i]):
                    if k == 3:
                        ndp[n][1][1] += dp[j][1][0] + dp[j][0][0]
                    else:
                        ndp[n][1][1] += dp[j][1][0]
                        ndp[n][0][1] += dp[j][0][0]
                elif k == int(N[i]):
                    if k == 3:
                        ndp[n][1][0] += dp[j][1][0] + dp[j][0][0]
                    else:
                        ndp[n][1][0] += dp[j][1][0]
                        ndp[n][0][0] += dp[j][0][0]
                ndp[n][1][1] %= mod
                ndp[n][1][0] %= mod
                ndp[n][0][1] %= mod
                ndp[n][0][0] %= mod
        dp = ndp
    return dp


dpb = solve(B)
dpa = solve(str(int(A) - 1))

ans = 0
for i in range(24):
    for j in range(2):
        if (i % 3 == 0 or j == 1) and i % 8 != 0:
            ans += sum(dpb[i][j]) - sum(dpa[i][j])
            ans %= mod
print(ans)
0