結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー GER_chenGER_chen
提出日時 2021-03-06 01:46:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,787 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 224,180 KB
最終ジャッジ日時 2024-04-16 17:23:17
合計ジャッジ時間 5,355 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
52,608 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 42 ms
52,992 KB
testcase_04 AC 41 ms
52,608 KB
testcase_05 AC 41 ms
53,248 KB
testcase_06 AC 41 ms
52,608 KB
testcase_07 AC 42 ms
52,864 KB
testcase_08 AC 41 ms
52,736 KB
testcase_09 AC 41 ms
52,736 KB
testcase_10 AC 42 ms
53,248 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = list(map(int, input()))
mod = 10**9+7
l = len(N)
D = [[[0]*3 for _ in range(3)] for _ in range(l)]

n = N[0]-1
D[0][0][2] = n//4
D[0][0][1] = n//2-n//4
D[0][1][0] = n//5
D[0][0][0] = n-n//2-n//5+1

num = n+1
if num in {3, 7, 9}:
    num = 1
if num == 8:
    num = 4
if num == 6:
    num = 2
    
for i in range(1, l):
    n = N[i]-1
    a_4 = n//4
    a_2 = n//2-n//4
    a_5 = n//5
    a_1 = n-n//2-n//5
    
    m = n+1
    if m in {3, 7, 9}:
        m = 1
    if m == 8:
        m = 4
    if m == 6:
        m = 2
        
    D[i][0][0] = D[i-1][0][0]*4
    D[i][0][1] = D[i-1][0][1]*4+D[i-1][0][0]*2
    D[i][0][2] = D[i-1][0][2]*8+D[i-1][0][1]*4+D[i-1][0][0]*2
    D[i][1][0] = D[i-1][0][0]+D[i-1][1][0]*4
    D[i][1][1] = D[i-1][0][1]+D[i-1][1][0]*2+D[i-1][1][1]*4
    D[i][1][2] = D[i-1][0][2]+D[i-1][1][0]*2+D[i-1][1][1]*4+D[i-1][1][2]*8
    D[i][2][0] = D[i-1][1][0]+D[i-1][2][0]*5
    D[i][2][1] = D[i-1][1][1]+D[i-1][2][0]*2+D[i-1][2][1]*5
    D[i][2][2] = D[i-1][1][2]+D[i-1][2][0]*2+D[i-1][2][1]*4+D[i-1][2][2]*9
    
    if num:
        if n >= 0:
            if num == 1:
                D[i][0][2] += a_4
                D[i][0][1] += a_2
                D[i][1][0] += a_5
                D[i][0][0] += a_1
            if num == 2:
                D[i][0][2] += a_4
                D[i][0][2] += a_2
                D[i][1][1] += a_5
                D[i][0][1] += a_1
            if num == 4:
                D[i][0][2] += a_4
                D[i][0][2] += a_2
                D[i][1][2] += a_5
                D[i][0][2] += a_1
            if num == 5:
                D[i][1][2] += a_4
                D[i][1][1] += a_2
                D[i][2][0] += a_5
                D[i][1][0] += a_1
            if num == 10:
                D[i][1][2] += a_4
                D[i][1][2] += a_2
                D[i][2][1] += a_5
                D[i][1][1] += a_1
            if num == 20:
                D[i][1][2] += a_4
                D[i][1][2] += a_2
                D[i][2][2] += a_5
                D[i][1][2] += a_1
            if num == 25:
                D[i][2][2] += a_4
                D[i][2][1] += a_2
                D[i][2][0] += a_5
                D[i][2][0] += a_1
            if num == 50:
                D[i][2][2] += a_4
                D[i][2][2] += a_2
                D[i][2][1] += a_5
                D[i][2][1] += a_1
            if num == 100:
                D[i][2][2] += a_4
                D[i][2][2] += a_2
                D[i][2][2] += a_5
                D[i][2][2] += a_1
        else:
            num = 0  
        num *= m
        if not num%16:
            num //= 4
        elif not num%8:
            num //= 2
        elif not num%125:
            num //= 5
            
ans = D[-1][2][2]%mod
if num == 100:
    ans += 1
print(ans)
0