結果

問題 No.314 ケンケンパ
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-04 22:00:27
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 401 bytes
コンパイル時間 3,540 ms
コンパイル使用メモリ 74,652 KB
実行使用メモリ 49,032 KB
最終ジャッジ日時 2024-04-17 00:28:48
合計ジャッジ時間 6,992 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
49,032 KB
testcase_01 AC 134 ms
41,464 KB
testcase_02 AC 135 ms
41,132 KB
testcase_03 AC 136 ms
41,324 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 135 ms
41,232 KB
testcase_07 AC 134 ms
40,984 KB
testcase_08 AC 133 ms
41,288 KB
testcase_09 AC 136 ms
41,548 KB
testcase_10 AC 133 ms
41,088 KB
testcase_11 AC 134 ms
41,216 KB
testcase_12 AC 135 ms
41,296 KB
testcase_13 AC 133 ms
41,344 KB
testcase_14 AC 133 ms
41,500 KB
testcase_15 AC 133 ms
41,380 KB
testcase_16 AC 134 ms
41,320 KB
testcase_17 AC 137 ms
42,052 KB
testcase_18 AC 153 ms
45,224 KB
testcase_19 AC 157 ms
48,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise59{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    long m = (long)(Math.pow(10, 9) + 7);

    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]) % m;
    }

    System.out.println(dp[n - 1]);
  }
}
0