結果

問題 No.44 DPなすごろく
ユーザー holegumaholeguma
提出日時 2015-08-05 19:57:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 370 bytes
コンパイル時間 1,713 ms
コンパイル使用メモリ 74,420 KB
実行使用メモリ 50,420 KB
最終ジャッジ日時 2024-07-18 03:32:01
合計ジャッジ時間 3,819 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,316 KB
testcase_01 AC 50 ms
50,236 KB
testcase_02 AC 51 ms
49,904 KB
testcase_03 AC 51 ms
50,204 KB
testcase_04 AC 50 ms
50,308 KB
testcase_05 AC 49 ms
50,368 KB
testcase_06 AC 47 ms
50,300 KB
testcase_07 AC 51 ms
50,196 KB
testcase_08 AC 48 ms
50,320 KB
testcase_09 AC 47 ms
50,308 KB
testcase_10 AC 46 ms
50,052 KB
testcase_11 AC 49 ms
50,220 KB
testcase_12 AC 48 ms
50,356 KB
testcase_13 AC 51 ms
50,256 KB
testcase_14 AC 49 ms
50,364 KB
testcase_15 AC 51 ms
50,152 KB
testcase_16 AC 51 ms
50,316 KB
testcase_17 AC 50 ms
50,316 KB
testcase_18 AC 47 ms
50,232 KB
testcase_19 AC 50 ms
50,288 KB
testcase_20 AC 48 ms
50,316 KB
testcase_21 AC 49 ms
50,068 KB
testcase_22 AC 47 ms
50,420 KB
testcase_23 AC 48 ms
50,276 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