結果

問題 No.260 世界のなんとか3
ユーザー qqqqqqqq
提出日時 2019-04-15 20:44:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 762 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 11,868 KB
実行使用メモリ 48,636 KB
最終ジャッジ日時 2023-10-22 06:46:47
合計ジャッジ時間 9,397 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 781 ms
46,704 KB
testcase_01 AC 474 ms
42,412 KB
testcase_02 AC 491 ms
42,412 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
from itertools import product
mod = 10**9+7

a, b = input().split()

def calc(s):
    keta = len(s)
    # keta, tight, mod3, is3, mod8
    dp = np.zeros((keta+1,2,3,2,8))
    dp[0][1][0][0][0] = 1
    for i, j, k, l, m in product(range(keta), range(2), range(3), range(2), range(8)):
        top = int(s[i]) if j else 9
        for n in range(top+1):
            dp[i+1][int(j and n== top)][(k+n)%3][int(l or n==3)][(2*m+n)%8] += dp[i][j][k][l][m]
            dp[i+1][int(j and n== top)][(k+n)%3][int(l or n==3)][(2*m+n)%8] %= mod
    ret = 0
    ret += dp[-1,0:2,0:3,1,1:].sum()
    ret += dp[-1,0:2,0,0:2,1:].sum()
    ret -= dp[-1,0:2,0,1,1:].sum()
    ret %= mod
    return int(ret)

ans = calc(b)-calc(str(int(a)-1))
ans %= mod
print(ans)
0