結果

問題 No.786 京都大学の過去問
ユーザー masamasa
提出日時 2019-02-26 10:30:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 2,521 ms
コンパイル使用メモリ 74,208 KB
実行使用メモリ 55,804 KB
最終ジャッジ日時 2023-09-02 12:49:36
合計ジャッジ時間 3,899 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,560 KB
testcase_01 AC 127 ms
55,584 KB
testcase_02 AC 129 ms
55,760 KB
testcase_03 AC 127 ms
55,588 KB
testcase_04 AC 127 ms
55,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Consumer<Integer> consumer = (num) -> {
        	long[] array = new long[num];
        	for (int i = 0; i < num; i++) {
        		if (i == 0) array[i] = 1;
        		else if (i == 1) array[i] = 2;
        		else array[i] = array[i-1] + array[i-2];
        	}
        	
        	System.out.println(array[num-1]);
        };
        
        consumer.accept(sc.nextInt());
    }
}
0