結果

問題 No.314 ケンケンパ
ユーザー nakamura sosukenakamura sosuke
提出日時 2019-07-08 10:02:23
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 456 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 144,128 KB
最終ジャッジ日時 2024-04-16 20:08:37
合計ジャッジ時間 8,814 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 84 ms
12,288 KB
testcase_02 AC 84 ms
12,032 KB
testcase_03 AC 86 ms
12,160 KB
testcase_04 AC 81 ms
12,160 KB
testcase_05 AC 83 ms
12,288 KB
testcase_06 AC 83 ms
12,160 KB
testcase_07 AC 86 ms
12,288 KB
testcase_08 AC 79 ms
12,288 KB
testcase_09 AC 78 ms
12,288 KB
testcase_10 AC 78 ms
12,032 KB
testcase_11 AC 80 ms
12,160 KB
testcase_12 AC 88 ms
12,160 KB
testcase_13 AC 89 ms
12,288 KB
testcase_14 AC 97 ms
12,800 KB
testcase_15 AC 106 ms
13,184 KB
testcase_16 AC 128 ms
15,232 KB
testcase_17 AC 250 ms
24,832 KB
testcase_18 AC 875 ms
74,496 KB
testcase_19 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = 10**9 + 7

dp = Array.new(N+1){ Array.new(2){ Array.new(2) { 0 } } }
# i = 1
dp[1][0][0] = 0 # パ
dp[1][1][0] = 1 # ケン0
dp[1][1][1] = 0 # ケン1

2.upto(N) do | i |
  # パ          ケン0           ケン1
  dp[i][0][0] = (dp[i-1][1][0] + dp[i-1][1][1]) % A
  # ケン0       パ
  dp[i][1][0] = (dp[i-1][0][0]) % A
  # ケン1       ケン0
  dp[i][1][1] = (dp[i-1][1][0]) % A
end

p (dp[N][0][0] + dp[N][1][0] + dp[N][1][1]) % A
0