結果

問題 No.44 DPなすごろく
ユーザー bambambambam
提出日時 2019-08-22 13:04:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 403 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 73,560 KB
実行使用メモリ 41,660 KB
最終ジャッジ日時 2024-04-20 12:03:12
合計ジャッジ時間 6,473 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
39,768 KB
testcase_01 AC 135 ms
41,612 KB
testcase_02 AC 134 ms
41,660 KB
testcase_03 AC 132 ms
41,060 KB
testcase_04 AC 132 ms
41,196 KB
testcase_05 AC 137 ms
41,068 KB
testcase_06 AC 135 ms
40,916 KB
testcase_07 AC 136 ms
41,116 KB
testcase_08 AC 122 ms
39,784 KB
testcase_09 AC 135 ms
41,016 KB
testcase_10 AC 129 ms
41,040 KB
testcase_11 AC 123 ms
40,976 KB
testcase_12 AC 123 ms
41,616 KB
testcase_13 AC 125 ms
40,952 KB
testcase_14 AC 127 ms
41,396 KB
testcase_15 AC 137 ms
41,536 KB
testcase_16 AC 134 ms
41,384 KB
testcase_17 AC 120 ms
40,028 KB
testcase_18 AC 120 ms
41,556 KB
testcase_19 AC 136 ms
41,148 KB
testcase_20 AC 122 ms
40,088 KB
testcase_21 AC 139 ms
41,200 KB
testcase_22 AC 132 ms
41,404 KB
testcase_23 AC 132 ms
41,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	static boolean memo[];
	static int ans, min;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		long[] dp = new long[n + 1];
		dp[0] = 1;
		dp[1] = 1;
		for (int i = 2; i <= n; i++) {
			dp[i] = dp[i - 1] + dp[i - 2];
		}
		System.out.println(dp[n]);
	}
}
0