結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
54,040 KB
testcase_01 AC 114 ms
54,016 KB
testcase_02 AC 104 ms
52,928 KB
testcase_03 AC 119 ms
53,984 KB
testcase_04 AC 103 ms
53,112 KB
testcase_05 AC 113 ms
54,140 KB
testcase_06 AC 121 ms
53,680 KB
testcase_07 AC 119 ms
54,300 KB
testcase_08 AC 119 ms
53,864 KB
testcase_09 AC 116 ms
54,156 KB
testcase_10 AC 118 ms
54,204 KB
testcase_11 AC 107 ms
53,084 KB
testcase_12 AC 117 ms
54,224 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 120 ms
53,892 KB
testcase_16 AC 119 ms
54,328 KB
testcase_17 AC 128 ms
54,036 KB
testcase_18 AC 132 ms
53,568 KB
testcase_19 AC 140 ms
53,304 KB
権限があれば一括ダウンロードができます

ソースコード

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%beki);
	}
}
0