結果

問題 No.314 ケンケンパ
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-14 16:34:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 155 ms / 1,000 ms
コード長 461 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 74,040 KB
実行使用メモリ 63,808 KB
最終ジャッジ日時 2023-10-25 01:58:21
合計ジャッジ時間 5,900 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
63,808 KB
testcase_01 AC 134 ms
57,576 KB
testcase_02 AC 134 ms
57,540 KB
testcase_03 AC 136 ms
57,640 KB
testcase_04 AC 134 ms
57,632 KB
testcase_05 AC 133 ms
57,680 KB
testcase_06 AC 138 ms
57,496 KB
testcase_07 AC 137 ms
57,548 KB
testcase_08 AC 132 ms
57,540 KB
testcase_09 AC 135 ms
57,600 KB
testcase_10 AC 135 ms
57,600 KB
testcase_11 AC 132 ms
55,444 KB
testcase_12 AC 132 ms
57,504 KB
testcase_13 AC 134 ms
57,440 KB
testcase_14 AC 137 ms
57,220 KB
testcase_15 AC 134 ms
57,484 KB
testcase_16 AC 136 ms
57,560 KB
testcase_17 AC 137 ms
57,604 KB
testcase_18 AC 150 ms
60,212 KB
testcase_19 AC 155 ms
63,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long MOD = (long)Math.pow(10, 9) + 7;
    int N = sc.nextInt();
    // dp[i]は長さ(i+1)のコース数 mod MOD
    long[] dp = new long[N];
    dp[0] = 1;
    if(1 < N) dp[1] = 2;
    if(2 < N) dp[2] = 2;
    for(int i = 3; i < N; i++) {
      dp[i] = (dp[i - 2] + dp[i - 3]) % MOD;
    }
    System.out.println(dp[N - 1]);
  }
}
0