結果

問題 No.44 DPなすごろく
ユーザー hhgfhn1hhgfhn1
提出日時 2018-10-18 10:58:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 342 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 74,796 KB
実行使用メモリ 54,288 KB
最終ジャッジ日時 2024-04-23 02:03:25
合計ジャッジ時間 5,337 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
52,916 KB
testcase_01 AC 101 ms
52,900 KB
testcase_02 AC 123 ms
54,288 KB
testcase_03 AC 117 ms
54,180 KB
testcase_04 AC 103 ms
52,952 KB
testcase_05 AC 112 ms
54,216 KB
testcase_06 AC 104 ms
52,876 KB
testcase_07 AC 114 ms
54,132 KB
testcase_08 AC 112 ms
54,076 KB
testcase_09 AC 112 ms
53,940 KB
testcase_10 AC 124 ms
53,840 KB
testcase_11 AC 117 ms
53,856 KB
testcase_12 AC 111 ms
53,504 KB
testcase_13 AC 119 ms
54,024 KB
testcase_14 AC 107 ms
53,484 KB
testcase_15 AC 121 ms
54,132 KB
testcase_16 AC 103 ms
53,060 KB
testcase_17 AC 119 ms
54,136 KB
testcase_18 AC 116 ms
53,976 KB
testcase_19 AC 114 ms
53,980 KB
testcase_20 AC 110 ms
53,632 KB
testcase_21 AC 118 ms
54,076 KB
testcase_22 AC 119 ms
54,168 KB
testcase_23 AC 104 ms
52,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long dp[]=new long[n+1];
		dp[0]=0;
		dp[1]=1;
		dp[2]=2;
		for(int i=3;i<=n;i++){
			dp[i]=dp[i-1]+dp[i-2];
		}
		System.out.println(dp[n]);
	}
}
0