結果

問題 No.314 ケンケンパ
ユーザー jp_stejp_ste
提出日時 2016-02-18 13:00:27
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 386 bytes
コンパイル時間 4,288 ms
コンパイル使用メモリ 74,928 KB
実行使用メモリ 63,868 KB
最終ジャッジ日時 2023-10-23 18:05:06
合計ジャッジ時間 6,123 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
63,792 KB
testcase_01 AC 133 ms
57,156 KB
testcase_02 AC 136 ms
57,120 KB
testcase_03 AC 138 ms
57,400 KB
testcase_04 RE -
testcase_05 AC 135 ms
57,376 KB
testcase_06 AC 136 ms
57,564 KB
testcase_07 AC 134 ms
57,400 KB
testcase_08 AC 137 ms
57,116 KB
testcase_09 AC 140 ms
57,148 KB
testcase_10 AC 140 ms
57,428 KB
testcase_11 AC 141 ms
57,368 KB
testcase_12 AC 142 ms
57,120 KB
testcase_13 AC 137 ms
57,084 KB
testcase_14 AC 140 ms
57,436 KB
testcase_15 AC 137 ms
57,396 KB
testcase_16 AC 138 ms
57,388 KB
testcase_17 AC 139 ms
57,472 KB
testcase_18 AC 151 ms
59,796 KB
testcase_19 AC 155 ms
63,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scan = new Scanner(System.in)) {
			int N = scan.nextInt();
			long dp[] = new long[N+1];
			dp[0] = 1;
			dp[1] = 2;
			dp[2] = 2;
			if(N >= 3) {
				for(int i=3; i<=N; i++) {
					dp[i] = ( dp[i-2] + dp[i-3] ) % (1000000000+7);
				}
			}
			System.out.println(dp[N-1]);
		}
	}
}
0