結果

問題 No.314 ケンケンパ
ユーザー Daigo HIROOKA
提出日時 2018-05-24 23:17:36
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 3,169 ms
コンパイル使用メモリ 74,432 KB
実行使用メモリ 45,088 KB
最終ジャッジ日時 2024-06-28 17:34:15
合計ジャッジ時間 6,222 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 11
権限があれば一括ダウンロードができます

ソースコード

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