結果

問題 No.314 ケンケンパ
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-24 23:17:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 3,419 ms
コンパイル使用メモリ 72,188 KB
実行使用メモリ 58,548 KB
最終ジャッジ日時 2023-09-11 03:02:56
合計ジャッジ時間 6,934 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 115 ms
39,748 KB
testcase_02 AC 117 ms
39,688 KB
testcase_03 AC 118 ms
39,464 KB
testcase_04 AC 119 ms
39,260 KB
testcase_05 AC 118 ms
39,380 KB
testcase_06 AC 117 ms
39,292 KB
testcase_07 AC 121 ms
39,672 KB
testcase_08 AC 117 ms
39,512 KB
testcase_09 AC 116 ms
39,532 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.*;

public class No314{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N == 1) System.out.println(1);
		else if(N == 2) System.out.println(2);
		else{
			long KK = 1;
			long KP = 1;
			long PK = 0;
			long[] kk_kp_pk = new long[3];
			while(N-2 > 0){
				kk_kp_pk = kenkenpa(KK, KP, PK);
				KK = kk_kp_pk[0];
				KP = kk_kp_pk[1];
				PK = kk_kp_pk[2];
				N--;
			}
			System.out.println((int)((KK+KP+PK)%(Math.pow(10, 9)+7)));
		}
		
	}
	private static long[] kenkenpa(long KK, long KP, long PK){
		long[] kk_kp_pk = {PK, KK+PK, KP};
		return kk_kp_pk;
	}
}
0