結果

問題 No.44 DPなすごろく
ユーザー Mcpu3Mcpu3
提出日時 2018-09-21 22:52:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 393 bytes
コンパイル時間 2,542 ms
コンパイル使用メモリ 70,976 KB
実行使用メモリ 56,512 KB
最終ジャッジ日時 2023-09-25 10:52:22
合計ジャッジ時間 5,943 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,012 KB
testcase_01 AC 122 ms
55,956 KB
testcase_02 AC 118 ms
55,580 KB
testcase_03 AC 121 ms
56,320 KB
testcase_04 AC 119 ms
56,136 KB
testcase_05 AC 119 ms
55,712 KB
testcase_06 AC 120 ms
55,632 KB
testcase_07 AC 117 ms
55,824 KB
testcase_08 AC 120 ms
56,072 KB
testcase_09 AC 120 ms
56,448 KB
testcase_10 AC 118 ms
56,188 KB
testcase_11 AC 119 ms
55,836 KB
testcase_12 AC 119 ms
56,140 KB
testcase_13 AC 119 ms
55,868 KB
testcase_14 AC 120 ms
56,244 KB
testcase_15 AC 121 ms
55,848 KB
testcase_16 AC 117 ms
56,512 KB
testcase_17 AC 119 ms
55,488 KB
testcase_18 AC 121 ms
56,112 KB
testcase_19 AC 122 ms
55,456 KB
testcase_20 AC 119 ms
55,892 KB
testcase_21 AC 119 ms
55,940 KB
testcase_22 AC 122 ms
55,648 KB
testcase_23 AC 122 ms
56,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong(),t[]=new long[3];
        sc.close();
        t[0]=1;
        t[1]=2;
        for(int i=2;i<n;++i){
            t[2]=t[0]+t[1];
            t[0]=t[1];
            t[1]=t[2];
        }
        System.out.print(t[1]);
    }
}
0