結果

問題 No.314 ケンケンパ
ユーザー tobusakanatobusakana
提出日時 2022-11-26 13:30:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 209 ms / 1,000 ms
コード長 333 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 173,008 KB
最終ジャッジ日時 2024-04-10 14:45:36
合計ジャッジ時間 2,339 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 209 ms
171,412 KB
testcase_01 AC 36 ms
52,888 KB
testcase_02 AC 31 ms
53,040 KB
testcase_03 AC 33 ms
53,208 KB
testcase_04 AC 33 ms
52,072 KB
testcase_05 AC 31 ms
52,936 KB
testcase_06 AC 31 ms
52,140 KB
testcase_07 AC 31 ms
52,340 KB
testcase_08 AC 31 ms
53,020 KB
testcase_09 AC 32 ms
52,664 KB
testcase_10 AC 34 ms
54,100 KB
testcase_11 AC 38 ms
59,384 KB
testcase_12 AC 39 ms
60,948 KB
testcase_13 AC 39 ms
60,964 KB
testcase_14 AC 37 ms
60,940 KB
testcase_15 AC 37 ms
62,160 KB
testcase_16 AC 39 ms
65,304 KB
testcase_17 AC 46 ms
74,356 KB
testcase_18 AC 124 ms
123,420 KB
testcase_19 AC 208 ms
173,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
DIV = 10 ** 9 + 7

# dp[i][s] = i番目が、0:ケン1回目,1:ケン2回目,パ
dp = [[0] * 3 for i in range(N)]
dp[0][0] = 1

for i in range(1, N):
  dp[i][0] += dp[i - 1][2]
  dp[i][1] += dp[i - 1][0]
  dp[i][2] += dp[i - 1][0] + dp[i - 1][1]
  for j in range(3):
    dp[i][j] %= DIV
    
print(sum(dp[-1]) % DIV)
0