結果

問題 No.314 ケンケンパ
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-14 16:33:20
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 441 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 74,084 KB
実行使用メモリ 63,924 KB
最終ジャッジ日時 2023-10-25 01:57:02
合計ジャッジ時間 5,806 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
63,708 KB
testcase_01 AC 128 ms
57,476 KB
testcase_02 AC 130 ms
57,436 KB
testcase_03 AC 129 ms
57,400 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 115 ms
56,256 KB
testcase_07 AC 127 ms
57,396 KB
testcase_08 AC 131 ms
57,248 KB
testcase_09 AC 128 ms
57,384 KB
testcase_10 AC 127 ms
57,192 KB
testcase_11 AC 126 ms
57,592 KB
testcase_12 AC 126 ms
57,448 KB
testcase_13 AC 117 ms
56,184 KB
testcase_14 AC 128 ms
57,600 KB
testcase_15 AC 125 ms
57,276 KB
testcase_16 AC 132 ms
57,544 KB
testcase_17 AC 136 ms
57,604 KB
testcase_18 AC 145 ms
60,080 KB
testcase_19 AC 148 ms
63,924 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;
    dp[1] = 2;
    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