結果

問題 No.44 DPなすごろく
ユーザー リチウムリチウム
提出日時 2014-10-25 15:11:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 306 bytes
コンパイル時間 1,992 ms
コンパイル使用メモリ 71,412 KB
実行使用メモリ 56,096 KB
最終ジャッジ日時 2023-08-28 23:03:30
合計ジャッジ時間 6,221 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
54,240 KB
testcase_01 AC 125 ms
55,980 KB
testcase_02 AC 124 ms
55,644 KB
testcase_03 AC 122 ms
55,972 KB
testcase_04 AC 120 ms
55,656 KB
testcase_05 AC 123 ms
55,936 KB
testcase_06 AC 124 ms
55,736 KB
testcase_07 AC 122 ms
55,648 KB
testcase_08 AC 123 ms
55,860 KB
testcase_09 AC 123 ms
55,748 KB
testcase_10 AC 128 ms
55,740 KB
testcase_11 AC 123 ms
55,616 KB
testcase_12 AC 121 ms
55,680 KB
testcase_13 AC 122 ms
55,316 KB
testcase_14 AC 123 ms
55,816 KB
testcase_15 AC 122 ms
55,720 KB
testcase_16 AC 123 ms
55,300 KB
testcase_17 AC 122 ms
55,708 KB
testcase_18 AC 123 ms
55,760 KB
testcase_19 AC 123 ms
55,400 KB
testcase_20 AC 125 ms
55,980 KB
testcase_21 AC 122 ms
56,096 KB
testcase_22 AC 121 ms
55,596 KB
testcase_23 AC 125 ms
55,840 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 ans[]=new long[n];
			ans[0]=1;
			ans[1]=2;
			for(int i=2;i<n;i++){
				ans[i]=ans[i-1]+ans[i-2];
			}
			System.out.println(ans[n-1]);
	}
	}
0