結果

問題 No.44 DPなすごろく
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-02-24 16:58:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 2,050 ms
コンパイル使用メモリ 72,484 KB
実行使用メモリ 56,204 KB
最終ジャッジ日時 2023-08-24 20:40:59
合計ジャッジ時間 6,380 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,804 KB
testcase_01 AC 122 ms
56,204 KB
testcase_02 AC 123 ms
55,844 KB
testcase_03 AC 121 ms
55,772 KB
testcase_04 AC 119 ms
56,024 KB
testcase_05 AC 123 ms
55,840 KB
testcase_06 AC 120 ms
55,936 KB
testcase_07 AC 123 ms
56,120 KB
testcase_08 AC 123 ms
56,204 KB
testcase_09 AC 122 ms
56,076 KB
testcase_10 AC 123 ms
55,720 KB
testcase_11 AC 121 ms
56,032 KB
testcase_12 AC 124 ms
55,812 KB
testcase_13 AC 125 ms
55,848 KB
testcase_14 AC 123 ms
55,584 KB
testcase_15 AC 125 ms
56,100 KB
testcase_16 AC 125 ms
55,776 KB
testcase_17 AC 125 ms
55,996 KB
testcase_18 AC 126 ms
55,836 KB
testcase_19 AC 124 ms
56,028 KB
testcase_20 AC 121 ms
55,880 KB
testcase_21 AC 123 ms
55,916 KB
testcase_22 AC 119 ms
56,192 KB
testcase_23 AC 119 ms
54,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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