結果

問題 No.314 ケンケンパ
ユーザー tobusakanatobusakana
提出日時 2022-11-26 13:33:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 1,000 ms
コード長 252 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 82,708 KB
実行使用メモリ 75,904 KB
最終ジャッジ日時 2024-04-10 14:49:02
合計ジャッジ時間 2,052 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,888 KB
testcase_01 AC 36 ms
52,096 KB
testcase_02 AC 35 ms
52,352 KB
testcase_03 AC 38 ms
52,132 KB
testcase_04 AC 30 ms
52,352 KB
testcase_05 AC 31 ms
51,840 KB
testcase_06 AC 31 ms
52,096 KB
testcase_07 AC 31 ms
52,096 KB
testcase_08 AC 32 ms
52,480 KB
testcase_09 AC 30 ms
52,480 KB
testcase_10 AC 31 ms
52,096 KB
testcase_11 AC 34 ms
58,496 KB
testcase_12 AC 37 ms
59,392 KB
testcase_13 AC 36 ms
59,520 KB
testcase_14 AC 37 ms
60,032 KB
testcase_15 AC 36 ms
60,800 KB
testcase_16 AC 38 ms
63,104 KB
testcase_17 AC 43 ms
72,576 KB
testcase_18 AC 57 ms
75,904 KB
testcase_19 AC 71 ms
75,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [0] * 3
dp[0] = 1

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