結果

問題 No.786 京都大学の過去問
ユーザー GrenacheGrenache
提出日時 2019-04-28 11:20:30
言語 Java19
(openjdk 21)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 3,547 ms
コンパイル使用メモリ 72,868 KB
実行使用メモリ 56,008 KB
最終ジャッジ日時 2023-08-21 17:48:26
合計ジャッジ時間 4,846 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,008 KB
testcase_01 AC 121 ms
55,680 KB
testcase_02 AC 121 ms
55,632 KB
testcase_03 AC 121 ms
55,712 KB
testcase_04 AC 121 ms
55,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Scanner;


public class Main_yukicoder786 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		long[] dp = new long[n + 1];
		dp[0] = 1;
		
		for (int i = 0; i < n; i++) {
			dp[i + 1] += dp[i];
			if (i + 2 <= n) {
				dp[i + 2] += dp[i];
			}
		}
		
		pr.println(dp[n]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0