結果

問題 No.189 SUPER HAPPY DAY
ユーザー e-mone-mon
提出日時 2015-04-23 20:36:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,330 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 86,692 KB
実行使用メモリ 130,544 KB
最終ジャッジ日時 2023-09-18 08:42:14
合計ジャッジ時間 9,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 237 ms
103,932 KB
testcase_01 AC 242 ms
104,036 KB
testcase_02 AC 237 ms
103,956 KB
testcase_03 AC 248 ms
104,140 KB
testcase_04 AC 245 ms
104,152 KB
testcase_05 AC 246 ms
103,908 KB
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 245 ms
103,832 KB
testcase_11 RE -
testcase_12 AC 251 ms
103,880 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 240 ms
104,204 KB
testcase_24 AC 241 ms
103,832 KB
testcase_25 AC 248 ms
104,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)

M,D = map(int,input().split())
length = 200
dp = [[False for i in range(1800+2)] for j in range(length)]
dp[0][0] = 1
for i in range(1,10):
    dp[0][i] = 1
for n in range(1,length):
    dp[n] = dp[n-1]+[]
    for i in range(1,10):
        for d in range(1800+2)[::-1]:
            if d+i < 1800+2 and dp[n-1][d] is not False: 
                dp[n][d+i] += dp[n-1][d]

#ある桁数のその数字までの値を求める
def hoge(digit,n):
    xs = [0 for i in range(1800+2)]
    upper = 0
    for i in range(int(n)):
        for d in range(1800+2)[::-1]:
            if d+i < 1800+2: 
                xs[d+i] += dp[digit-1][d]
    return xs

def solve(num,digit):
    #numまでは足して,numになったらnum以降の数字で出来たものにnumを足したものを返す
    if digit == 0 or num == 0:
        a = [1 if i <= num else 0 for i in range(0,1800+2)]
        return a
    n = int(str(num)[0])
    a = hoge(digit,n)
    b = solve(int(str(num)[1:]),digit-1)
    for i in range(1800+2):
        if i+n < 1800+2:
            a[i+n] += b[i]
    return a

M_count = solve(M,len(str(M))-1)

D_count = solve(D,len(str(D))-1)

ans = 0
for i in range(1,1800+2):
    ans += M_count[i] * D_count[i] %(10**9+9)
print(ans%(10**9+9))
0