結果

問題 No.44 DPなすごろく
ユーザー 37zigen37zigen
提出日時 2016-03-25 19:58:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 321 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 74,712 KB
実行使用メモリ 54,492 KB
最終ジャッジ日時 2024-04-09 23:53:26
合計ジャッジ時間 6,407 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
54,308 KB
testcase_01 AC 135 ms
54,156 KB
testcase_02 AC 133 ms
54,160 KB
testcase_03 AC 132 ms
54,100 KB
testcase_04 AC 133 ms
54,124 KB
testcase_05 AC 132 ms
54,188 KB
testcase_06 AC 134 ms
54,116 KB
testcase_07 AC 136 ms
54,100 KB
testcase_08 AC 136 ms
53,848 KB
testcase_09 AC 134 ms
54,492 KB
testcase_10 AC 137 ms
54,144 KB
testcase_11 AC 134 ms
54,060 KB
testcase_12 AC 134 ms
54,076 KB
testcase_13 AC 135 ms
54,220 KB
testcase_14 AC 134 ms
54,036 KB
testcase_15 AC 134 ms
53,976 KB
testcase_16 AC 133 ms
54,060 KB
testcase_17 AC 131 ms
54,112 KB
testcase_18 AC 133 ms
54,124 KB
testcase_19 AC 133 ms
54,448 KB
testcase_20 AC 134 ms
54,016 KB
testcase_21 AC 137 ms
54,160 KB
testcase_22 AC 135 ms
53,872 KB
testcase_23 AC 132 ms
54,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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