結果

問題 No.44 DPなすごろく
ユーザー kano_townkano_town
提出日時 2014-12-08 21:35:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 323 bytes
コンパイル時間 3,939 ms
コンパイル使用メモリ 71,648 KB
実行使用メモリ 56,076 KB
最終ジャッジ日時 2023-09-02 11:47:06
合計ジャッジ時間 7,716 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,524 KB
testcase_01 AC 130 ms
55,712 KB
testcase_02 AC 130 ms
55,628 KB
testcase_03 AC 130 ms
56,076 KB
testcase_04 AC 127 ms
53,432 KB
testcase_05 AC 130 ms
55,780 KB
testcase_06 AC 129 ms
55,724 KB
testcase_07 AC 129 ms
55,800 KB
testcase_08 AC 130 ms
55,488 KB
testcase_09 AC 130 ms
55,796 KB
testcase_10 AC 132 ms
55,996 KB
testcase_11 AC 131 ms
55,628 KB
testcase_12 AC 130 ms
55,708 KB
testcase_13 AC 131 ms
55,836 KB
testcase_14 AC 128 ms
53,604 KB
testcase_15 AC 129 ms
55,720 KB
testcase_16 AC 128 ms
55,724 KB
testcase_17 AC 128 ms
55,452 KB
testcase_18 AC 129 ms
56,000 KB
testcase_19 AC 129 ms
55,724 KB
testcase_20 AC 129 ms
55,776 KB
testcase_21 AC 128 ms
55,708 KB
testcase_22 AC 130 ms
55,784 KB
testcase_23 AC 126 ms
55,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder44 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		long[] dp = new long[n + 1];
		dp[0] = dp[1] = 1;
		for (int i = 2; i <= n; i++) dp[i] = dp[i - 1] + dp[i - 2];
		System.out.println(dp[n]);
	}
}
0