結果

問題 No.44 DPなすごろく
ユーザー mits58mits58
提出日時 2016-07-02 22:04:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 305 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 74,008 KB
実行使用メモリ 54,344 KB
最終ジャッジ日時 2024-04-20 06:14:26
合計ジャッジ時間 5,903 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
54,100 KB
testcase_01 AC 125 ms
53,680 KB
testcase_02 AC 138 ms
54,124 KB
testcase_03 AC 118 ms
54,256 KB
testcase_04 AC 105 ms
52,696 KB
testcase_05 AC 115 ms
53,956 KB
testcase_06 AC 112 ms
53,936 KB
testcase_07 AC 122 ms
54,076 KB
testcase_08 AC 107 ms
52,884 KB
testcase_09 AC 115 ms
54,052 KB
testcase_10 AC 112 ms
53,548 KB
testcase_11 AC 106 ms
52,864 KB
testcase_12 AC 136 ms
54,084 KB
testcase_13 AC 136 ms
54,240 KB
testcase_14 AC 133 ms
54,344 KB
testcase_15 AC 128 ms
54,148 KB
testcase_16 AC 132 ms
54,144 KB
testcase_17 AC 109 ms
52,912 KB
testcase_18 AC 121 ms
54,000 KB
testcase_19 AC 118 ms
54,140 KB
testcase_20 AC 100 ms
52,504 KB
testcase_21 AC 131 ms
53,992 KB
testcase_22 AC 138 ms
54,212 KB
testcase_23 AC 136 ms
54,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			long[] dp=new long[51];
			int n=sc.nextInt();
			dp[0]=1; dp[1]=1;
			for(int i=2;i<51;i++) dp[i]+=dp[i-1]+dp[i-2];
			System.out.println(dp[n]);
		}
	}
}
0