結果

問題 No.44 DPなすごろく
ユーザー kuramukuramu
提出日時 2016-01-30 21:48:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 60 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 2,676 ms
コンパイル使用メモリ 74,688 KB
実行使用メモリ 53,440 KB
最終ジャッジ日時 2023-10-21 18:11:21
合計ジャッジ時間 5,370 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
52,404 KB
testcase_01 AC 58 ms
52,396 KB
testcase_02 AC 56 ms
51,380 KB
testcase_03 AC 58 ms
53,368 KB
testcase_04 AC 56 ms
53,432 KB
testcase_05 AC 57 ms
52,364 KB
testcase_06 AC 56 ms
53,428 KB
testcase_07 AC 55 ms
53,424 KB
testcase_08 AC 56 ms
53,420 KB
testcase_09 AC 55 ms
53,440 KB
testcase_10 AC 57 ms
53,428 KB
testcase_11 AC 57 ms
52,384 KB
testcase_12 AC 57 ms
52,320 KB
testcase_13 AC 57 ms
52,360 KB
testcase_14 AC 58 ms
52,388 KB
testcase_15 AC 57 ms
53,432 KB
testcase_16 AC 56 ms
53,432 KB
testcase_17 AC 58 ms
53,428 KB
testcase_18 AC 57 ms
53,432 KB
testcase_19 AC 59 ms
52,328 KB
testcase_20 AC 59 ms
53,432 KB
testcase_21 AC 55 ms
51,468 KB
testcase_22 AC 60 ms
53,436 KB
testcase_23 AC 57 ms
53,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	 public static void main(String[] args) {
	      BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
	      try {
	    	  int N = Integer.parseInt(stdReader.readLine());
	    	  long[] dp = new long[N+1];
	    	  dp[0] = 1;
	    	  dp[1] = 1;
	    	  for(int i=2;i<N+1;i++){
	    		  dp[i] = dp[i-1] + dp[i-2];
	    	  }
	    	  System.out.println(dp[N]);
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
}
0