結果

問題 No.189 SUPER HAPPY DAY
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-11 00:19:10
言語 Python2
(2.7.18)
結果
AC  
実行時間 1,604 ms / 5,000 ms
コード長 1,056 bytes
コンパイル時間 995 ms
コンパイル使用メモリ 6,596 KB
実行使用メモリ 59,824 KB
最終ジャッジ日時 2023-09-20 01:51:01
合計ジャッジ時間 20,917 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 473 ms
55,212 KB
testcase_01 AC 486 ms
55,392 KB
testcase_02 AC 482 ms
55,300 KB
testcase_03 AC 485 ms
55,344 KB
testcase_04 AC 485 ms
55,232 KB
testcase_05 AC 483 ms
55,388 KB
testcase_06 AC 485 ms
55,284 KB
testcase_07 AC 484 ms
55,424 KB
testcase_08 AC 488 ms
55,204 KB
testcase_09 AC 482 ms
55,284 KB
testcase_10 AC 481 ms
55,340 KB
testcase_11 AC 484 ms
55,216 KB
testcase_12 AC 483 ms
55,380 KB
testcase_13 AC 783 ms
57,184 KB
testcase_14 AC 904 ms
57,248 KB
testcase_15 AC 942 ms
58,912 KB
testcase_16 AC 1,033 ms
59,808 KB
testcase_17 AC 1,050 ms
59,496 KB
testcase_18 AC 915 ms
58,692 KB
testcase_19 AC 1,089 ms
58,212 KB
testcase_20 AC 650 ms
56,748 KB
testcase_21 AC 634 ms
56,232 KB
testcase_22 AC 495 ms
55,592 KB
testcase_23 AC 1,039 ms
59,816 KB
testcase_24 AC 1,044 ms
59,824 KB
testcase_25 AC 1,604 ms
59,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M,D=map(int,raw_input().split())
mod=1000000009

def getTable(M):
    dp1=[[[0 for i in range(2)] for j in range(1810)] for k in range(202)]
    Mb=1
    dp1[0][0][0]=1
    while Mb*10<=M:
        Mb*=10
    ind=0
    while Mb>0:
        b=M/Mb
        for s in range(1809,-1,-1):
            if dp1[ind][s][0]>0:
                for i in range(b):
                    dp1[ind+1][s+i][1]+=dp1[ind][s][0]
                    dp1[ind+1][s+i][1]%=mod
                dp1[ind+1][s+b][0]+=dp1[ind][s][0]
                dp1[ind+1][s+b][0]%=mod
            if dp1[ind][s][1]>0:
                for i in range(10):
                    dp1[ind+1][s+i][1]+=dp1[ind][s][1]
                    dp1[ind+1][s+i][1]%=mod
        ind+=1
        M%=Mb
        Mb/=10
    return dp1[ind]

dpM=getTable(M)
dpD=getTable(D)
ans=0
for i in range(1,1809):
    #if dpM[i][0]!=0 or dpM[i][1]!=0 or dpD[i][0]!=0 or dpD[i][1]!=0:
    #    print  i,":",dpM[i][0],"+",dpM[i][1],"...",dpD[i][0],"+",dpD[i][1]
    ans+=(dpM[i][0]+dpM[i][1])*(dpD[i][0]+dpD[i][1])
    ans%=mod
print ans
0