結果

問題 No.44 DPなすごろく
ユーザー shinwisteriashinwisteria
提出日時 2017-03-31 14:54:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 336 bytes
コンパイル時間 2,895 ms
コンパイル使用メモリ 71,908 KB
実行使用メモリ 56,908 KB
最終ジャッジ日時 2023-09-21 10:37:47
合計ジャッジ時間 6,747 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,740 KB
testcase_01 AC 114 ms
55,772 KB
testcase_02 AC 116 ms
56,368 KB
testcase_03 AC 115 ms
55,820 KB
testcase_04 AC 115 ms
55,684 KB
testcase_05 AC 114 ms
55,460 KB
testcase_06 AC 115 ms
56,120 KB
testcase_07 AC 116 ms
55,664 KB
testcase_08 AC 117 ms
56,364 KB
testcase_09 AC 116 ms
55,624 KB
testcase_10 AC 115 ms
56,224 KB
testcase_11 AC 115 ms
55,824 KB
testcase_12 AC 116 ms
56,032 KB
testcase_13 AC 116 ms
56,176 KB
testcase_14 AC 117 ms
55,644 KB
testcase_15 AC 118 ms
53,852 KB
testcase_16 AC 119 ms
55,940 KB
testcase_17 AC 118 ms
55,912 KB
testcase_18 AC 121 ms
56,564 KB
testcase_19 AC 118 ms
55,668 KB
testcase_20 AC 118 ms
56,212 KB
testcase_21 AC 118 ms
55,724 KB
testcase_22 AC 119 ms
56,908 KB
testcase_23 AC 118 ms
55,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class DPsugoroku {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		s.close();
		long[] root = new long[N+1];
		root[1] = 1;
		root[2] = 2;
		for(int i =3;i <= N;i++){
			root[i] = root[i-1] + root[i-2];
		}
		System.out.println(root[N]);

	}

}
0