結果

問題 No.220 世界のなんとか2
ユーザー tomatonosuketomatonosuke
提出日時 2017-04-02 02:07:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 1,000 ms
コード長 606 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 76,104 KB
最終ジャッジ日時 2023-09-22 02:29:48
合計ジャッジ時間 2,914 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,132 KB
testcase_01 AC 74 ms
71,012 KB
testcase_02 AC 75 ms
71,228 KB
testcase_03 AC 75 ms
71,212 KB
testcase_04 AC 75 ms
71,308 KB
testcase_05 AC 75 ms
71,380 KB
testcase_06 AC 75 ms
71,316 KB
testcase_07 AC 74 ms
71,284 KB
testcase_08 AC 73 ms
71,268 KB
testcase_09 AC 73 ms
71,372 KB
testcase_10 AC 75 ms
71,128 KB
testcase_11 AC 76 ms
71,444 KB
testcase_12 AC 76 ms
71,228 KB
testcase_13 AC 76 ms
71,148 KB
testcase_14 AC 78 ms
75,968 KB
testcase_15 AC 80 ms
76,104 KB
testcase_16 AC 80 ms
76,052 KB
testcase_17 AC 80 ms
76,064 KB
testcase_18 AC 81 ms
76,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

power = int(input())
target = str(10 ** power)
length = len(target)
dp = [[[[0 for l in range(3)] for m in range(2)] for n in range(2)] for k in range(length + 1)]
dp[0][0][0][0] = 1
for i,t in enumerate(target):
    for flag in range(2):
        for div in range(2):
            for modu in range(3):
                limit = 9 if flag else int(t)
                for lim in range(limit + 1):
                    dp[i+1][flag or lim < int(t)][div or lim == 3][(modu * 10 + lim) % 3] += dp[i][flag][div][modu]
print(dp[length][1][1][0] + dp[length][1][1][1] + dp[length][1][1][2] + dp[length][1][0][0] - 1)
0