結果

問題 No.314 ケンケンパ
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 17:10:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 341 ms / 1,000 ms
コード長 644 bytes
コンパイル時間 3,881 ms
コンパイル使用メモリ 72,064 KB
実行使用メモリ 114,928 KB
最終ジャッジ日時 2023-09-22 02:05:44
合計ジャッジ時間 7,970 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 341 ms
114,880 KB
testcase_01 AC 133 ms
55,512 KB
testcase_02 AC 130 ms
55,744 KB
testcase_03 AC 132 ms
53,828 KB
testcase_04 AC 135 ms
55,736 KB
testcase_05 AC 133 ms
55,516 KB
testcase_06 AC 134 ms
55,496 KB
testcase_07 AC 137 ms
55,852 KB
testcase_08 AC 130 ms
55,512 KB
testcase_09 AC 134 ms
55,808 KB
testcase_10 AC 135 ms
56,000 KB
testcase_11 AC 131 ms
55,824 KB
testcase_12 AC 132 ms
55,732 KB
testcase_13 AC 130 ms
55,844 KB
testcase_14 AC 132 ms
55,772 KB
testcase_15 AC 136 ms
55,736 KB
testcase_16 AC 139 ms
58,044 KB
testcase_17 AC 155 ms
60,080 KB
testcase_18 AC 226 ms
79,900 KB
testcase_19 AC 335 ms
114,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Kenkenpa {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		s.close();
		long[][] root = new long[N+1][3];    //[i][0]がケン(1)、[i][1]がケン(2)、[i][2]がパ
		root[1][0] = 1;
		int t = (int)Math.pow(10, 9) + 7;
		for(int i = 2;i <= N;i++){
			root[i][0] = root[i-1][2];
			root[i][1] = root[i-1][0];
			root[i][2] = root[i-1][0] + root[i-1][1];
			root[i][0] %= t;
			root[i][1] %= t;
			root[i][2] %= t;
		}
		System.out.println((root[N][0] + root[N][1] + root[N][2]) % t);

	}

}
0