結果

問題 No.44 DPなすごろく
ユーザー めうめう🎒めうめう🎒
提出日時 2016-05-06 16:11:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 486 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 74,636 KB
実行使用メモリ 42,020 KB
最終ジャッジ日時 2024-04-15 13:31:02
合計ジャッジ時間 7,119 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
41,100 KB
testcase_01 AC 154 ms
41,484 KB
testcase_02 AC 155 ms
41,764 KB
testcase_03 AC 150 ms
42,020 KB
testcase_04 AC 150 ms
41,724 KB
testcase_05 AC 153 ms
41,740 KB
testcase_06 AC 152 ms
41,456 KB
testcase_07 AC 151 ms
41,648 KB
testcase_08 AC 151 ms
41,804 KB
testcase_09 AC 151 ms
41,828 KB
testcase_10 AC 153 ms
41,452 KB
testcase_11 AC 152 ms
41,484 KB
testcase_12 AC 146 ms
41,492 KB
testcase_13 AC 151 ms
41,784 KB
testcase_14 AC 149 ms
41,556 KB
testcase_15 AC 162 ms
41,600 KB
testcase_16 AC 152 ms
41,540 KB
testcase_17 AC 150 ms
41,868 KB
testcase_18 AC 147 ms
41,504 KB
testcase_19 AC 150 ms
41,472 KB
testcase_20 AC 151 ms
41,784 KB
testcase_21 AC 151 ms
41,660 KB
testcase_22 AC 150 ms
41,508 KB
testcase_23 AC 150 ms
41,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.Arrays;

class Main{
	static int n;
	static long memo[] = new long[51];

	static long saiki(int now){
		if(now == n) return 1;
		if(now >= n) return 0;
		if(memo[now] != -1) return memo[now];

		long sum = 0;
		sum += saiki(now + 1);
		sum += saiki(now + 2);
		return memo[now] = sum;
	}

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		Arrays.fill(memo,-1);
		System.out.println(saiki(0));
	}
}
0