結果

問題 No.44 DPなすごろく
ユーザー fjafjafjafjafjafja
提出日時 2017-09-25 23:47:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 298 bytes
コンパイル時間 3,219 ms
コンパイル使用メモリ 71,816 KB
実行使用メモリ 57,104 KB
最終ジャッジ日時 2023-08-09 07:05:11
合計ジャッジ時間 7,794 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,680 KB
testcase_01 AC 125 ms
55,604 KB
testcase_02 AC 125 ms
55,476 KB
testcase_03 AC 123 ms
55,800 KB
testcase_04 AC 123 ms
55,908 KB
testcase_05 AC 126 ms
57,104 KB
testcase_06 AC 127 ms
55,548 KB
testcase_07 AC 127 ms
55,772 KB
testcase_08 AC 127 ms
55,452 KB
testcase_09 AC 128 ms
55,552 KB
testcase_10 AC 126 ms
55,704 KB
testcase_11 AC 127 ms
55,696 KB
testcase_12 AC 124 ms
55,552 KB
testcase_13 AC 125 ms
55,672 KB
testcase_14 AC 126 ms
55,812 KB
testcase_15 AC 124 ms
55,492 KB
testcase_16 AC 125 ms
55,844 KB
testcase_17 AC 122 ms
55,656 KB
testcase_18 AC 124 ms
55,836 KB
testcase_19 AC 125 ms
56,148 KB
testcase_20 AC 125 ms
55,716 KB
testcase_21 AC 127 ms
55,904 KB
testcase_22 AC 121 ms
55,204 KB
testcase_23 AC 126 ms
55,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N44
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		long[] ans=new long[a];
		ans[0]=1;
		ans[1]=2;
		for(int i=2;i<a;i++)
		{
			ans[i]=ans[i-2]+ans[i-1];
		}
		System.out.println(ans[a-1]);
	}

}
0