結果

問題 No.189 SUPER HAPPY DAY
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-04-22 01:56:15
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 11,344 KB
実行使用メモリ 18,568 KB
最終ジャッジ日時 2023-09-18 07:41:30
合計ジャッジ時間 11,211 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,016 KB
testcase_01 AC 82 ms
15,192 KB
testcase_02 AC 81 ms
15,260 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
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 AC 827 ms
18,356 KB
testcase_24 AC 832 ms
18,372 KB
testcase_25 AC 1,584 ms
18,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

M, D = gets.split

def get_dp(s)
    dp = []
    # dp[0] = 1
    size = 0
    #puts "---------------"
    s.each_char{|ch|
        dp2 = []
        num = ch.ord - '0'.ord
        #puts "num=#{num}"
        (0..9).each{|i|
            (dp.size).downto(0).each{|j|
                dp2[j+i] = dp2[j+i].to_i + dp[j].to_i
                #puts "i=#{i}, j=#{j} dp2[#{j+i}]=#{dp2[j+i]}"
            }
        }
        (0..num-1).each{|j|
            dp2[j+size] = dp[j+size].to_i + 1
            #puts "j=#{j} size=#{size} dp2[j+size]=#{dp2[j+size]}"
        }
        dp = dp2
        size += num
    }
    dp[size] += 1
    return dp
end
dp1 = get_dp(M)
dp2 = get_dp(D)
total = 0
(1..dp1.size).each{|i|
    cnt = dp1[i].to_i * dp2[i].to_i
    total += cnt
    #puts "i=#{i}, db1[i]=#{dp1[i]}, dp2[i]=#{dp2[i]}"
}
puts total % 1000000009

0