結果

問題 No.314 ケンケンパ
ユーザー jp_stejp_ste
提出日時 2016-02-18 13:00:27
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 386 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 74,324 KB
実行使用メモリ 60,140 KB
最終ジャッジ日時 2024-09-22 11:56:11
合計ジャッジ時間 5,468 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
59,256 KB
testcase_01 AC 116 ms
53,068 KB
testcase_02 AC 128 ms
54,168 KB
testcase_03 AC 130 ms
54,176 KB
testcase_04 RE -
testcase_05 AC 127 ms
53,828 KB
testcase_06 AC 127 ms
54,108 KB
testcase_07 AC 129 ms
54,084 KB
testcase_08 AC 129 ms
54,128 KB
testcase_09 AC 130 ms
54,284 KB
testcase_10 AC 131 ms
54,232 KB
testcase_11 AC 133 ms
54,316 KB
testcase_12 AC 130 ms
53,944 KB
testcase_13 AC 129 ms
53,916 KB
testcase_14 AC 115 ms
52,768 KB
testcase_15 AC 129 ms
54,044 KB
testcase_16 AC 130 ms
53,944 KB
testcase_17 AC 134 ms
54,400 KB
testcase_18 AC 137 ms
56,644 KB
testcase_19 AC 139 ms
60,140 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