結果

問題 No.314 ケンケンパ
ユーザー tentententen
提出日時 2020-10-06 12:28:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 269 ms / 1,000 ms
コード長 464 bytes
コンパイル時間 4,635 ms
コンパイル使用メモリ 71,728 KB
実行使用メモリ 90,076 KB
最終ジャッジ日時 2023-09-27 06:56:35
合計ジャッジ時間 6,115 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 269 ms
87,752 KB
testcase_01 AC 120 ms
55,844 KB
testcase_02 AC 118 ms
56,572 KB
testcase_03 AC 121 ms
55,848 KB
testcase_04 AC 118 ms
54,052 KB
testcase_05 AC 120 ms
55,844 KB
testcase_06 AC 121 ms
55,552 KB
testcase_07 AC 119 ms
55,944 KB
testcase_08 AC 121 ms
55,460 KB
testcase_09 AC 121 ms
56,028 KB
testcase_10 AC 121 ms
56,196 KB
testcase_11 AC 123 ms
55,660 KB
testcase_12 AC 119 ms
55,876 KB
testcase_13 AC 117 ms
55,952 KB
testcase_14 AC 119 ms
56,016 KB
testcase_15 AC 122 ms
54,000 KB
testcase_16 AC 120 ms
55,760 KB
testcase_17 AC 136 ms
60,044 KB
testcase_18 AC 186 ms
71,532 KB
testcase_19 AC 263 ms
90,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] dp = new int[n + 1][3];
		dp[0][0] = 1;
		for (int i = 1; i <= n; i++) {
		    dp[i][0] = (dp[i - 1][1] + dp[i - 1][2]) % MOD;
		    dp[i][1] = dp[i - 1][0];
		    dp[i][2] = dp[i - 1][1];
		}
		System.out.println(((dp[n][0] + dp[n][1]) % MOD + dp[n][2]) % MOD);
	}
}
0