結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,136 KB
testcase_01 AC 44 ms
49,128 KB
testcase_02 AC 45 ms
49,336 KB
testcase_03 AC 45 ms
49,224 KB
testcase_04 AC 44 ms
49,080 KB
testcase_05 AC 44 ms
49,416 KB
testcase_06 AC 44 ms
49,220 KB
testcase_07 AC 44 ms
49,280 KB
testcase_08 AC 43 ms
49,416 KB
testcase_09 AC 45 ms
49,448 KB
testcase_10 AC 44 ms
49,144 KB
testcase_11 AC 44 ms
49,404 KB
testcase_12 AC 44 ms
49,148 KB
testcase_13 AC 45 ms
49,548 KB
testcase_14 AC 44 ms
49,312 KB
testcase_15 AC 45 ms
49,164 KB
testcase_16 AC 44 ms
49,312 KB
testcase_17 AC 45 ms
49,060 KB
testcase_18 AC 44 ms
49,416 KB
testcase_19 AC 45 ms
49,384 KB
testcase_20 AC 45 ms
49,676 KB
testcase_21 AC 45 ms
49,184 KB
testcase_22 AC 44 ms
49,416 KB
testcase_23 AC 44 ms
49,124 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