結果

問題 No.314 ケンケンパ
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 17:08:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 584 bytes
コンパイル時間 3,176 ms
コンパイル使用メモリ 72,420 KB
実行使用メモリ 117,536 KB
最終ジャッジ日時 2023-09-22 02:05:34
合計ジャッジ時間 7,573 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 124 ms
55,824 KB
testcase_02 AC 122 ms
55,516 KB
testcase_03 AC 122 ms
55,552 KB
testcase_04 AC 125 ms
56,000 KB
testcase_05 AC 123 ms
55,512 KB
testcase_06 AC 123 ms
55,780 KB
testcase_07 AC 123 ms
55,840 KB
testcase_08 AC 123 ms
55,620 KB
testcase_09 AC 122 ms
55,764 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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];
		}
		System.out.println((root[N][0] + root[N][1] + root[N][2]) % t);

	}

}
0