結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
54,132 KB
testcase_01 AC 119 ms
54,228 KB
testcase_02 AC 110 ms
53,288 KB
testcase_03 WA -
testcase_04 AC 111 ms
53,952 KB
testcase_05 AC 104 ms
52,920 KB
testcase_06 AC 114 ms
54,028 KB
testcase_07 AC 108 ms
52,984 KB
testcase_08 AC 106 ms
53,084 KB
testcase_09 WA -
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 AC 137 ms
54,508 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N314
{
	static int cnt=0;
	static int n;
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int length=2;
		int[] state=new int[3];
		int[] buf=new int[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];
				}
				state[0]=buf[2]%beki;
				state[1]=(buf[0]+buf[2])%beki;
				state[2]=buf[1]%beki;
				length++;
			}
			for(int i=0;i<3;i++)
			{
				cnt+=state[i];
			}
		}
		else
		{cnt=n;}
		System.out.println(cnt);
	}
}
0