結果

問題 No.44 DPなすごろく
ユーザー holegumaholeguma
提出日時 2015-08-05 19:57:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 370 bytes
コンパイル時間 1,884 ms
コンパイル使用メモリ 71,480 KB
実行使用メモリ 49,680 KB
最終ジャッジ日時 2023-09-25 04:01:37
合計ジャッジ時間 4,138 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,148 KB
testcase_01 AC 44 ms
49,116 KB
testcase_02 AC 43 ms
49,680 KB
testcase_03 AC 42 ms
49,140 KB
testcase_04 AC 44 ms
49,268 KB
testcase_05 AC 46 ms
49,320 KB
testcase_06 AC 46 ms
49,124 KB
testcase_07 AC 45 ms
49,148 KB
testcase_08 AC 46 ms
49,280 KB
testcase_09 AC 45 ms
49,216 KB
testcase_10 AC 46 ms
49,148 KB
testcase_11 AC 46 ms
49,132 KB
testcase_12 AC 45 ms
49,148 KB
testcase_13 AC 45 ms
49,132 KB
testcase_14 AC 45 ms
49,252 KB
testcase_15 AC 45 ms
49,388 KB
testcase_16 AC 45 ms
49,080 KB
testcase_17 AC 45 ms
49,212 KB
testcase_18 AC 45 ms
49,304 KB
testcase_19 AC 45 ms
49,188 KB
testcase_20 AC 46 ms
47,600 KB
testcase_21 AC 45 ms
49,312 KB
testcase_22 AC 46 ms
49,312 KB
testcase_23 AC 46 ms
49,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
long[] dp;
while((line=br.readLine())!=null){
int n=Integer.parseInt(line);
dp=new long[n+1];
dp[0]=1;
dp[1]=1;
for(int i=2;i<=n;i++){
dp[i]=dp[i-1]+dp[i-2];
}
System.out.println(dp[n]);
}
}
}
0