結果

問題 No.220 世界のなんとか2
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-16 01:36:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 32 ms / 1,000 ms
コード長 948 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 11,868 KB
実行使用メモリ 10,200 KB
最終ジャッジ日時 2023-10-20 08:42:17
合計ジャッジ時間 1,648 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,196 KB
testcase_01 AC 31 ms
10,196 KB
testcase_02 AC 30 ms
10,196 KB
testcase_03 AC 30 ms
10,196 KB
testcase_04 AC 30 ms
10,196 KB
testcase_05 AC 30 ms
10,196 KB
testcase_06 AC 31 ms
10,196 KB
testcase_07 AC 31 ms
10,196 KB
testcase_08 AC 30 ms
10,196 KB
testcase_09 AC 30 ms
10,196 KB
testcase_10 AC 30 ms
10,196 KB
testcase_11 AC 30 ms
10,196 KB
testcase_12 AC 31 ms
10,200 KB
testcase_13 AC 31 ms
10,200 KB
testcase_14 AC 31 ms
10,200 KB
testcase_15 AC 32 ms
10,200 KB
testcase_16 AC 31 ms
10,200 KB
testcase_17 AC 31 ms
10,200 KB
testcase_18 AC 32 ms
10,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p = int(input())
S = "1" + "0" * p

# iけた、j以下、k3がある、mod3=l

dp = [[[[0] * 3 for _ in range(2)] for _ in range(2)] for _ in range(p + 2)]
dp[0][0][0][0] = 1
for i in range(p + 1):
    nd = 1 if i == 0 else 0
    for j in range(2):
        for k in range(2):
            for l in range(3):
                for d in range(10):
                    ni = i + 1
                    nj = j
                    nk = k
                    nl = (l + d) % 3
                    if nj == 0:
                        if d > nd:
                            continue
                        if d < nd:
                            nj = 1
                    if d == 3:
                        nk = 1
                    dp[ni][nj][nk][nl] += dp[i][j][k][l]

ans = 0
for j in range(2):
    for k in range(2):
        for l in range(3):
            if k == 0 and l != 0:
                continue
            ans += dp[p + 1][j][k][l]
print(ans - 1)
0