結果
問題 |
No.314 ケンケンパ
|
ユーザー |
|
提出日時 | 2025-09-01 13:44:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 319 ms / 1,000 ms |
コード長 | 1,296 bytes |
コンパイル時間 | 460 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 174,560 KB |
最終ジャッジ日時 | 2025-09-01 13:44:18 |
合計ジャッジ時間 | 3,810 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right # 0~9を並び替えるならpermutationsかconbinations,N列のカテゴリを作るにはproduct from itertools import product, permutations, combinations, accumulate from functools import lru_cache # @lru_cache(maxsize=128) import operator from string import ascii_uppercase, ascii_lowercase, digits # 英字(大文字), 英字(小文字), 数字 MOD = 10 ** 9 + 7 def II(): return int(input()) def LI(): return list(input()) def LMI(): return list(map(int, input().split())) def LMS(): return list(map(str, input().split())) def LLMI(x): return [list(map(int, input().split())) for _ in range(x)] def LLMS(x): return [list(input()) for _ in range(x)] def execute(): n = II() dp = [[0] * 3 for _ in range(n)] dp[0][0] = 1 for i in range(n-1): for k in range(3): dp[i+1][(k+1)%3] += dp[i][k] dp[i+1][(k+1)%3] %= MOD if k == 0: dp[i+1][2] += dp[i][k] dp[i+1][2] %= MOD # else: # dp[i+1][k] = dp[i][k] print(sum(dp[-1])%MOD) # print(dp) if __name__ == "__main__": T = 1 for _ in range(T): execute()