結果

問題 No.44 DPなすごろく
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-15 16:25:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 299 bytes
コンパイル時間 3,500 ms
コンパイル使用メモリ 72,256 KB
実行使用メモリ 58,292 KB
最終ジャッジ日時 2023-08-26 22:35:19
合計ジャッジ時間 7,083 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,104 KB
testcase_01 AC 116 ms
55,968 KB
testcase_02 AC 116 ms
56,128 KB
testcase_03 AC 115 ms
56,180 KB
testcase_04 AC 113 ms
56,448 KB
testcase_05 AC 117 ms
56,112 KB
testcase_06 AC 118 ms
55,852 KB
testcase_07 AC 117 ms
56,016 KB
testcase_08 AC 119 ms
55,944 KB
testcase_09 AC 120 ms
56,104 KB
testcase_10 AC 118 ms
56,068 KB
testcase_11 AC 121 ms
55,596 KB
testcase_12 AC 119 ms
56,068 KB
testcase_13 AC 120 ms
56,096 KB
testcase_14 AC 120 ms
55,436 KB
testcase_15 AC 120 ms
55,928 KB
testcase_16 AC 117 ms
58,292 KB
testcase_17 AC 112 ms
56,108 KB
testcase_18 AC 116 ms
55,868 KB
testcase_19 AC 115 ms
55,916 KB
testcase_20 AC 117 ms
56,052 KB
testcase_21 AC 115 ms
55,808 KB
testcase_22 AC 116 ms
56,552 KB
testcase_23 AC 111 ms
56,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No44 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long n1 = 1;
		long n2 = 0;
		long n = 2;
		for(int i = 3;i <= N;i++) {
			n2 = n1;
			n1 = n;
			n = n1 + n2;
		}
		System.out.println(n);
	}
}
0