結果

問題 No.314 ケンケンパ
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-04 21:56:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 401 bytes
コンパイル時間 3,981 ms
コンパイル使用メモリ 74,780 KB
実行使用メモリ 60,328 KB
最終ジャッジ日時 2024-04-17 00:28:26
合計ジャッジ時間 7,245 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 135 ms
41,436 KB
testcase_02 AC 135 ms
41,184 KB
testcase_03 AC 135 ms
41,272 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 134 ms
41,236 KB
testcase_07 AC 134 ms
41,368 KB
testcase_08 AC 135 ms
41,104 KB
testcase_09 AC 136 ms
41,104 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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

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