結果

問題 No.314 ケンケンパ
ユーザー fjafjafjafjafjafja
提出日時 2017-09-19 12:13:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 1,000 ms
コード長 626 bytes
コンパイル時間 3,018 ms
コンパイル使用メモリ 74,512 KB
実行使用メモリ 54,496 KB
最終ジャッジ日時 2024-04-25 18:07:45
合計ジャッジ時間 6,253 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
53,312 KB
testcase_01 AC 115 ms
53,932 KB
testcase_02 AC 104 ms
52,852 KB
testcase_03 AC 107 ms
52,776 KB
testcase_04 AC 121 ms
54,328 KB
testcase_05 AC 110 ms
53,076 KB
testcase_06 AC 120 ms
54,380 KB
testcase_07 AC 118 ms
54,496 KB
testcase_08 AC 109 ms
52,836 KB
testcase_09 AC 105 ms
52,852 KB
testcase_10 AC 118 ms
53,904 KB
testcase_11 AC 115 ms
54,060 KB
testcase_12 AC 107 ms
53,048 KB
testcase_13 AC 124 ms
54,216 KB
testcase_14 AC 118 ms
53,548 KB
testcase_15 AC 119 ms
54,256 KB
testcase_16 AC 109 ms
52,924 KB
testcase_17 AC 130 ms
54,088 KB
testcase_18 AC 144 ms
54,160 KB
testcase_19 AC 151 ms
53,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N314
{
	static long cnt=0;
	static int n;
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int length=2;
		long[] state=new long[3];
		long[] buf=new long[3];
		int beki=(int)Math.pow(10, 9)+7;
		state[0]=1;state[1]=1;state[2]=0;
		if(n>2)
		{
			while(length!=n)
			{
				for(int i=0;i<3;i++)
				{
					buf[i]=state[i]%beki;
				}
				state[0]=buf[2];
				state[1]=(buf[0]+buf[2]);
				state[2]=buf[1];
				length++;
			}
			for(int i=0;i<3;i++)
			{
				cnt+=state[i];
			}
		}
		else
		{cnt=n;}
		System.out.println(cnt%beki);
	}
}
0