結果

問題 No.314 ケンケンパ
ユーザー 37zigen
提出日時 2016-03-25 20:11:33
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 73,804 KB
実行使用メモリ 58,424 KB
最終ジャッジ日時 2024-10-02 00:50:04
合計ジャッジ時間 6,018 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 5 WA * 12
権限があれば一括ダウンロードができます

ソースコード

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();
		int[] dp=new int[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