結果

問題 No.44 DPなすごろく
ユーザー uafr_csuafr_cs
提出日時 2015-06-03 17:22:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 438 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 72,000 KB
実行使用メモリ 56,676 KB
最終ジャッジ日時 2023-09-20 18:59:53
合計ジャッジ時間 6,022 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,296 KB
testcase_01 AC 122 ms
55,756 KB
testcase_02 AC 123 ms
55,896 KB
testcase_03 AC 123 ms
56,060 KB
testcase_04 AC 124 ms
55,896 KB
testcase_05 AC 123 ms
56,008 KB
testcase_06 AC 122 ms
55,880 KB
testcase_07 AC 120 ms
55,448 KB
testcase_08 AC 122 ms
55,992 KB
testcase_09 AC 121 ms
55,964 KB
testcase_10 AC 121 ms
53,780 KB
testcase_11 AC 121 ms
55,852 KB
testcase_12 AC 121 ms
55,920 KB
testcase_13 AC 121 ms
55,984 KB
testcase_14 AC 122 ms
56,140 KB
testcase_15 AC 123 ms
56,084 KB
testcase_16 AC 122 ms
55,988 KB
testcase_17 AC 122 ms
55,744 KB
testcase_18 AC 121 ms
55,748 KB
testcase_19 AC 122 ms
56,676 KB
testcase_20 AC 122 ms
55,596 KB
testcase_21 AC 122 ms
56,256 KB
testcase_22 AC 120 ms
55,956 KB
testcase_23 AC 122 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		long[] DP = new long[N + 1];
		DP[0] = 1;
		for(int cur = 0; cur < N; cur++){
			if(cur + 1 <= N){ DP[cur + 1] += DP[cur]; }
			if(cur + 2 <= N){ DP[cur + 2] += DP[cur]; }
		}
		
		System.out.println(DP[N]);
		
	}
	
}
0