結果

問題 No.314 ケンケンパ
ユーザー FromBooskaFromBooska
提出日時 2023-02-20 22:13:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 1,000 ms
コード長 459 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 75,892 KB
最終ジャッジ日時 2023-09-28 17:40:16
合計ジャッジ時間 3,103 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
75,848 KB
testcase_01 AC 75 ms
71,488 KB
testcase_02 AC 79 ms
71,244 KB
testcase_03 AC 75 ms
71,460 KB
testcase_04 AC 75 ms
71,440 KB
testcase_05 AC 75 ms
71,208 KB
testcase_06 AC 75 ms
71,192 KB
testcase_07 AC 78 ms
71,372 KB
testcase_08 AC 78 ms
71,060 KB
testcase_09 AC 75 ms
71,468 KB
testcase_10 AC 75 ms
71,588 KB
testcase_11 AC 76 ms
71,476 KB
testcase_12 AC 75 ms
71,240 KB
testcase_13 AC 75 ms
71,348 KB
testcase_14 AC 79 ms
75,740 KB
testcase_15 AC 80 ms
75,756 KB
testcase_16 AC 78 ms
75,856 KB
testcase_17 AC 81 ms
75,560 KB
testcase_18 AC 80 ms
75,768 KB
testcase_19 AC 85 ms
75,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# このやり方なら超簡単超高速
# https://sugarknri.hatenablog.com/entry/2016/05/25/185206
# a:「パで終わった」
# b:「ケンが1回で終わった」
# c:「ケンが2回で終わった」とする。このとき次の1歩を進むと
# aからはbになり、bからはaかcになり、cはaになる。

N = int(input())
mod = 10**9+7
a, b, c = 1, 0, 0
for i in range(N):
    a, b, c = (b+c)%mod, a%mod, b%mod
ans = (a+b+c)%mod
print(ans)
0