結果

問題 No.786 京都大学の過去問
ユーザー tentententen
提出日時 2020-09-01 08:44:19
言語 Java19
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 3,330 ms
コンパイル使用メモリ 71,564 KB
実行使用メモリ 55,916 KB
最終ジャッジ日時 2023-08-11 04:59:41
合計ジャッジ時間 4,500 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,700 KB
testcase_01 AC 122 ms
55,916 KB
testcase_02 AC 123 ms
55,640 KB
testcase_03 AC 125 ms
55,892 KB
testcase_04 AC 121 ms
55,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static long[] dp;
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	dp = new long[n + 1];
    	dp[0] = 1;
    	System.out.println(dfw(n));
    }
    
    static long dfw(int idx) {
        if (idx < 0) {
            return 0;
        }
        if (dp[idx] == 0) {
            dp[idx] = dfw(idx - 1) + dfw(idx - 2);
        }
        return dp[idx];
    }
}
0