結果

問題 No.220 世界のなんとか2
ユーザー 👑 rin204rin204
提出日時 2022-07-04 14:55:23
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 76 ms / 1,000 ms
コード長 399 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 71,496 KB
最終ジャッジ日時 2023-08-20 22:07:03
合計ジャッジ時間 2,962 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,172 KB
testcase_01 AC 70 ms
71,424 KB
testcase_02 AC 76 ms
71,256 KB
testcase_03 AC 72 ms
70,984 KB
testcase_04 AC 74 ms
71,424 KB
testcase_05 AC 76 ms
71,396 KB
testcase_06 AC 72 ms
71,308 KB
testcase_07 AC 72 ms
71,248 KB
testcase_08 AC 73 ms
71,336 KB
testcase_09 AC 72 ms
71,184 KB
testcase_10 AC 74 ms
71,304 KB
testcase_11 AC 72 ms
71,272 KB
testcase_12 AC 74 ms
71,496 KB
testcase_13 AC 75 ms
71,308 KB
testcase_14 AC 76 ms
71,140 KB
testcase_15 AC 76 ms
71,388 KB
testcase_16 AC 75 ms
71,424 KB
testcase_17 AC 74 ms
71,328 KB
testcase_18 AC 74 ms
71,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p = int(input())

dp = [0, 0, 0]
ans = 0
plus = 10 ** (p - 1)
for i in range(p):
    ans += (sum(dp) + 1) * plus
    plus //= 10
    ndp = [0] * 3
    for i in range(10):
        if i == 3:
            continue
        for j in range(3):
            ndp[(i + j) % 3] += dp[j]
    for i in range(1, 10):
        if i == 3:
            continue
        ndp[i % 3] += 1
    dp = ndp

print(ans + dp[0])
0