結果

問題 No.44 DPなすごろく
ユーザー scachescache
提出日時 2014-11-13 15:05:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 513 bytes
コンパイル時間 6,251 ms
コンパイル使用メモリ 71,760 KB
実行使用メモリ 56,204 KB
最終ジャッジ日時 2023-08-30 03:23:45
合計ジャッジ時間 7,691 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,992 KB
testcase_01 AC 125 ms
55,780 KB
testcase_02 AC 124 ms
55,828 KB
testcase_03 AC 123 ms
56,000 KB
testcase_04 AC 124 ms
55,924 KB
testcase_05 AC 125 ms
56,192 KB
testcase_06 AC 127 ms
55,844 KB
testcase_07 AC 131 ms
55,860 KB
testcase_08 AC 124 ms
55,992 KB
testcase_09 AC 124 ms
55,828 KB
testcase_10 AC 126 ms
55,972 KB
testcase_11 AC 123 ms
55,528 KB
testcase_12 AC 125 ms
55,972 KB
testcase_13 AC 124 ms
55,764 KB
testcase_14 AC 126 ms
56,020 KB
testcase_15 AC 124 ms
55,844 KB
testcase_16 AC 125 ms
55,572 KB
testcase_17 AC 124 ms
56,140 KB
testcase_18 AC 124 ms
55,948 KB
testcase_19 AC 125 ms
55,780 KB
testcase_20 AC 126 ms
55,724 KB
testcase_21 AC 127 ms
56,204 KB
testcase_22 AC 126 ms
55,832 KB
testcase_23 AC 125 ms
56,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


import java.util.Scanner;

/**
 * yukicoder no.44
 * @author scache
 *
 */
public class DpSugoroku {
	public static void main(String[] args) {
		DpSugoroku p = new DpSugoroku();
	}

	public DpSugoroku() {
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		
		solve(n);
	}

	public void solve(int n) {
		long[] dp = new long[n+2];
		
		dp[0] = 1;
		for(int i=0;i<dp.length-2;i++){
			dp[i+1] += dp[i];
			dp[i+2] += dp[i];
		}
		
		System.out.println(dp[n]);
	}

}
0