結果

問題 No.314 ケンケンパ
ユーザー hhgfhn1hhgfhn1
提出日時 2018-10-18 13:53:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 154 ms / 1,000 ms
コード長 371 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 74,424 KB
実行使用メモリ 48,976 KB
最終ジャッジ日時 2024-04-23 18:55:33
合計ジャッジ時間 5,820 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
48,056 KB
testcase_01 AC 133 ms
41,492 KB
testcase_02 AC 115 ms
40,072 KB
testcase_03 AC 128 ms
41,140 KB
testcase_04 AC 126 ms
41,532 KB
testcase_05 AC 113 ms
40,352 KB
testcase_06 AC 129 ms
41,596 KB
testcase_07 AC 131 ms
41,340 KB
testcase_08 AC 130 ms
40,972 KB
testcase_09 AC 129 ms
41,628 KB
testcase_10 AC 132 ms
41,336 KB
testcase_11 AC 131 ms
41,280 KB
testcase_12 AC 129 ms
41,544 KB
testcase_13 AC 135 ms
41,564 KB
testcase_14 AC 134 ms
41,448 KB
testcase_15 AC 130 ms
41,224 KB
testcase_16 AC 116 ms
40,508 KB
testcase_17 AC 136 ms
42,372 KB
testcase_18 AC 133 ms
44,624 KB
testcase_19 AC 154 ms
48,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int mod=1000000007;
		long dp[]=new long[n+3];
		dp[0]=1;
		dp[1]=2;
		dp[2]=2;
		for(int i=3;i<n;i++){
			dp[i]=(dp[i-3]+dp[i-2])%mod;
		}
		System.out.println(dp[n-1]);
	}
}
0