結果

問題 No.314 ケンケンパ
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-24 23:30:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 168 ms / 1,000 ms
コード長 680 bytes
コンパイル時間 3,248 ms
コンパイル使用メモリ 72,228 KB
実行使用メモリ 58,336 KB
最終ジャッジ日時 2023-09-11 03:03:31
合計ジャッジ時間 6,984 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
58,200 KB
testcase_01 AC 128 ms
55,780 KB
testcase_02 AC 128 ms
55,780 KB
testcase_03 AC 126 ms
55,780 KB
testcase_04 AC 123 ms
55,372 KB
testcase_05 AC 123 ms
55,484 KB
testcase_06 AC 125 ms
56,056 KB
testcase_07 AC 124 ms
55,572 KB
testcase_08 AC 122 ms
56,160 KB
testcase_09 AC 125 ms
55,776 KB
testcase_10 AC 126 ms
55,868 KB
testcase_11 AC 122 ms
56,408 KB
testcase_12 AC 123 ms
55,932 KB
testcase_13 AC 123 ms
55,820 KB
testcase_14 AC 127 ms
56,032 KB
testcase_15 AC 123 ms
54,228 KB
testcase_16 AC 126 ms
55,852 KB
testcase_17 AC 139 ms
58,216 KB
testcase_18 AC 149 ms
58,336 KB
testcase_19 AC 164 ms
58,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No314{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long mod = 1000000007;
		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]%mod;
				KP = kk_kp_pk[1]%mod;
				PK = kk_kp_pk[2]%mod;
				N--;
			}
			System.out.println((long)((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