結果

問題 No.314 ケンケンパ
ユーザー villachvillach
提出日時 2017-10-24 16:21:49
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 805 bytes
コンパイル時間 3,362 ms
コンパイル使用メモリ 77,940 KB
実行使用メモリ 765,768 KB
最終ジャッジ日時 2024-05-01 13:07:58
合計ジャッジ時間 12,301 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 130 ms
54,020 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 127 ms
53,932 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.math.BigDecimal;
import java.util.Scanner;

public class N314 {
	long[][] dp;
	int n;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		N314 inst = new N314();
		inst.solve(n);
	}
	
	public void solve(int n){
		this.n = n;
		dp = new long[n][n];
		System.out.println(BigDecimal.valueOf(calc(0, 0) % (Math.pow(10, 9) + 7)));
	}
	
	public long calc(int k, int l){
		long fuga;
		
		if(k >= this.n) return 1;
		
		if(dp[k][l] != 0){
			return dp[k][l];
		}
		
		if(l >= 2){
			fuga = calc(k + 1, 0);
			dp[k][l] = fuga;
			return fuga;
		}else if(l == 1){
			fuga = calc(k + 1, 2) + calc(k + 1, 0);
			dp[k][l] = fuga;
			return fuga;
		}else{
			fuga = calc(k + 1, 1);
			dp[k][l] = fuga;
			return fuga;
		}
	}
}
0