結果

問題 No.189 SUPER HAPPY DAY
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-04-22 02:00:10
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,666 ms / 5,000 ms
コード長 835 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 11,296 KB
実行使用メモリ 18,760 KB
最終ジャッジ日時 2023-09-18 07:43:15
合計ジャッジ時間 10,922 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,072 KB
testcase_01 AC 85 ms
15,132 KB
testcase_02 AC 83 ms
15,004 KB
testcase_03 AC 83 ms
15,252 KB
testcase_04 AC 82 ms
15,260 KB
testcase_05 AC 83 ms
15,260 KB
testcase_06 AC 83 ms
15,128 KB
testcase_07 AC 82 ms
15,208 KB
testcase_08 AC 82 ms
15,200 KB
testcase_09 AC 82 ms
15,112 KB
testcase_10 AC 82 ms
15,244 KB
testcase_11 AC 82 ms
15,092 KB
testcase_12 AC 84 ms
15,088 KB
testcase_13 AC 408 ms
15,992 KB
testcase_14 AC 550 ms
16,248 KB
testcase_15 AC 672 ms
18,328 KB
testcase_16 AC 847 ms
17,960 KB
testcase_17 AC 812 ms
18,168 KB
testcase_18 AC 633 ms
17,888 KB
testcase_19 AC 822 ms
17,176 KB
testcase_20 AC 265 ms
15,760 KB
testcase_21 AC 220 ms
15,456 KB
testcase_22 AC 89 ms
15,000 KB
testcase_23 AC 846 ms
18,388 KB
testcase_24 AC 852 ms
18,360 KB
testcase_25 AC 1,666 ms
18,760 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] = dp2[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