結果

問題 No.220 世界のなんとか2
ユーザー moharan627moharan627
提出日時 2021-08-21 14:23:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 1,000 ms
コード長 1,322 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 54,780 KB
最終ジャッジ日時 2024-04-23 05:45:46
合計ジャッジ時間 1,427 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,152 KB
testcase_01 AC 38 ms
53,160 KB
testcase_02 AC 37 ms
53,760 KB
testcase_03 AC 38 ms
53,024 KB
testcase_04 AC 34 ms
53,624 KB
testcase_05 AC 32 ms
52,548 KB
testcase_06 AC 32 ms
53,164 KB
testcase_07 AC 34 ms
52,928 KB
testcase_08 AC 34 ms
53,116 KB
testcase_09 AC 35 ms
53,020 KB
testcase_10 AC 35 ms
53,056 KB
testcase_11 AC 36 ms
52,868 KB
testcase_12 AC 35 ms
52,960 KB
testcase_13 AC 33 ms
54,060 KB
testcase_14 AC 34 ms
53,508 KB
testcase_15 AC 33 ms
53,668 KB
testcase_16 AC 33 ms
52,780 KB
testcase_17 AC 34 ms
54,780 KB
testcase_18 AC 34 ms
53,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
INF = float('inf')
#10**20,2**63,float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
#from collections import defaultdict
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    P = II()
    N = [1] + [0]*P
    L = len(N)
    Less = [[[0 for _ in range(3)] for _ in range(2)] for _ in range(L + 1)]
    Less[1][1][0] = 1
    Less[1][0][0] = 2
    Less[1][0][1] = 3
    Less[1][0][2] = 3
    Ans = 0
    for i in range(L):
        for n in range(10):
            if n == 3:
                for m in range(3):
                    Less[i+1][1][(m+n)%3] += Less[i][0][m]
                    Less[i+1][1][(m+n)%3] += Less[i][1][m]
            else:
                for m in range(3):
                    Less[i+1][0][(m+n)%3] += Less[i][0][m]
                    Less[i+1][1][(m+n)%3] += Less[i][1][m]
        #print("Less:",Less[i+1])
        Ans += sum(Less[i][1]) + Less[i][0][0]
    # 小さいサンプルでの確認は大事。
    # print("Equ:",Equ)
    # print("Less:",Less)
    print(Ans)
    return
solve()
#sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!!
0