結果

問題 No.220 世界のなんとか2
ユーザー finefine
提出日時 2016-04-29 01:28:33
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 1,000 ms
コード長 422 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 11,504 KB
実行使用メモリ 15,336 KB
最終ジャッジ日時 2023-08-27 06:16:45
合計ジャッジ時間 2,735 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,248 KB
testcase_01 AC 78 ms
15,292 KB
testcase_02 AC 76 ms
15,132 KB
testcase_03 AC 76 ms
15,232 KB
testcase_04 AC 74 ms
15,240 KB
testcase_05 AC 81 ms
15,128 KB
testcase_06 AC 80 ms
15,020 KB
testcase_07 AC 79 ms
15,120 KB
testcase_08 AC 76 ms
15,304 KB
testcase_09 AC 77 ms
15,184 KB
testcase_10 AC 77 ms
15,336 KB
testcase_11 AC 76 ms
15,132 KB
testcase_12 AC 79 ms
15,112 KB
testcase_13 AC 79 ms
15,132 KB
testcase_14 AC 78 ms
15,140 KB
testcase_15 AC 77 ms
15,196 KB
testcase_16 AC 79 ms
15,028 KB
testcase_17 AC 74 ms
15,224 KB
testcase_18 AC 75 ms
15,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

P = gets.to_i
a = Array.new(P + 1)
(P + 1).times{|i|
    a[i] = Array.new(9 * P + 1, 0)
    }

a[0][0] = 1
ans1 = ans2 = 0
1.upto(P){|i|
    10.times{|x|
        if x == 3
            next
        end
        0.upto(9 * i - x){|j|
            a[i][j + x] += a[i - 1][j]
            }
        }
    ans2 = 9 * ans2 + 10 ** (i - 1)
    ans1 = 0
    3.step(9 * i, 3){|x|
        ans1 += a[i][x]
        }
    }
p ans1 + ans2
0