結果

問題 No.44 DPなすごろく
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-25 19:35:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 341 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 71,472 KB
実行使用メモリ 56,544 KB
最終ジャッジ日時 2023-08-18 07:36:54
合計ジャッジ時間 5,972 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,532 KB
testcase_01 AC 119 ms
55,792 KB
testcase_02 AC 120 ms
55,908 KB
testcase_03 AC 122 ms
56,260 KB
testcase_04 AC 122 ms
55,608 KB
testcase_05 AC 120 ms
54,480 KB
testcase_06 AC 121 ms
55,848 KB
testcase_07 AC 122 ms
55,736 KB
testcase_08 AC 120 ms
55,708 KB
testcase_09 AC 120 ms
56,092 KB
testcase_10 AC 120 ms
55,980 KB
testcase_11 AC 118 ms
55,760 KB
testcase_12 AC 120 ms
55,788 KB
testcase_13 AC 122 ms
55,788 KB
testcase_14 AC 123 ms
55,880 KB
testcase_15 AC 119 ms
55,732 KB
testcase_16 AC 119 ms
55,792 KB
testcase_17 AC 118 ms
56,544 KB
testcase_18 AC 119 ms
55,988 KB
testcase_19 AC 117 ms
55,708 KB
testcase_20 AC 119 ms
56,132 KB
testcase_21 AC 117 ms
55,780 KB
testcase_22 AC 120 ms
55,740 KB
testcase_23 AC 122 ms
55,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    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