結果

問題 No.786 京都大学の過去問
ユーザー htensaihtensai
提出日時 2019-12-10 00:57:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 1,935 ms
コンパイル使用メモリ 71,324 KB
実行使用メモリ 56,168 KB
最終ジャッジ日時 2023-09-05 15:31:17
合計ジャッジ時間 3,302 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,824 KB
testcase_01 AC 126 ms
55,748 KB
testcase_02 AC 125 ms
55,956 KB
testcase_03 AC 124 ms
56,168 KB
testcase_04 AC 124 ms
55,756 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[] arr = new long[n + 1];
        arr[0] = 1;
        arr[1] = 1;
        for (int i = 2; i <= n; i++) {
            arr[i] = arr[i - 2] + arr[i - 1];
        }
        System.out.println(arr[n]);
    }
}
0