結果

問題 No.314 ケンケンパ
ユーザー 37zigen37zigen
提出日時 2016-03-25 20:13:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 74,012 KB
実行使用メモリ 60,316 KB
最終ジャッジ日時 2024-04-09 23:53:38
合計ジャッジ時間 5,308 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 126 ms
54,132 KB
testcase_02 AC 124 ms
54,308 KB
testcase_03 WA -
testcase_04 AC 126 ms
53,932 KB
testcase_05 AC 125 ms
54,244 KB
testcase_06 AC 116 ms
53,128 KB
testcase_07 AC 120 ms
54,048 KB
testcase_08 AC 125 ms
54,212 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 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder314;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[] dp=new long[n+1];
		dp[0]=0;///ケン・ケン・パ ケン・パ
		dp[1]=0;
		if(n==1){
			System.out.println(1);
			return;
		}
		dp[2]=1;
		if(n==2){
			System.out.println(2);
			return;
		}
		dp[3]=1;
		if(n==3){
			System.out.println(2);
			return;
		}
		for(int i=4;i<=n;i++){
			dp[i]=dp[i-2]+dp[i-3];
		}
		System.out.println(dp[n]+dp[n-1]+dp[n-2]);
	}
}
0