結果

問題 No.44 DPなすごろく
ユーザー htensaihtensai
提出日時 2019-12-17 18:07:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 461 bytes
コンパイル時間 3,002 ms
コンパイル使用メモリ 71,648 KB
実行使用メモリ 49,532 KB
最終ジャッジ日時 2023-09-17 05:31:11
合計ジャッジ時間 5,263 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
49,316 KB
testcase_01 AC 36 ms
48,992 KB
testcase_02 AC 37 ms
49,184 KB
testcase_03 AC 39 ms
49,304 KB
testcase_04 AC 40 ms
49,152 KB
testcase_05 AC 38 ms
49,312 KB
testcase_06 AC 38 ms
49,324 KB
testcase_07 AC 38 ms
49,204 KB
testcase_08 AC 37 ms
49,076 KB
testcase_09 AC 37 ms
49,532 KB
testcase_10 AC 37 ms
49,176 KB
testcase_11 AC 38 ms
49,336 KB
testcase_12 AC 39 ms
49,532 KB
testcase_13 AC 38 ms
48,988 KB
testcase_14 AC 37 ms
49,272 KB
testcase_15 AC 39 ms
49,316 KB
testcase_16 AC 39 ms
49,244 KB
testcase_17 AC 39 ms
49,132 KB
testcase_18 AC 39 ms
49,136 KB
testcase_19 AC 38 ms
49,192 KB
testcase_20 AC 39 ms
49,128 KB
testcase_21 AC 39 ms
49,368 KB
testcase_22 AC 40 ms
49,216 KB
testcase_23 AC 39 ms
49,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        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