結果

問題 No.314 ケンケンパ
ユーザー TatsuDXTatsuDX
提出日時 2016-10-16 21:42:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 1,000 ms
コード長 440 bytes
コンパイル時間 3,561 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 41,344 KB
最終ジャッジ日時 2024-05-02 02:37:18
合計ジャッジ時間 7,000 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
39,988 KB
testcase_01 AC 135 ms
41,140 KB
testcase_02 AC 135 ms
40,980 KB
testcase_03 AC 132 ms
41,096 KB
testcase_04 AC 134 ms
41,304 KB
testcase_05 AC 134 ms
40,972 KB
testcase_06 AC 133 ms
41,176 KB
testcase_07 AC 132 ms
41,320 KB
testcase_08 AC 133 ms
41,344 KB
testcase_09 AC 131 ms
41,000 KB
testcase_10 AC 133 ms
41,168 KB
testcase_11 AC 133 ms
41,332 KB
testcase_12 AC 132 ms
40,856 KB
testcase_13 AC 137 ms
41,208 KB
testcase_14 AC 134 ms
41,160 KB
testcase_15 AC 132 ms
41,016 KB
testcase_16 AC 132 ms
40,916 KB
testcase_17 AC 139 ms
41,304 KB
testcase_18 AC 142 ms
41,120 KB
testcase_19 AC 147 ms
41,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		if(n < 3){
			System.out.println(n);
                        return;
		}
		long t00 = 1, t01 = 1, t10 = 0, tmp, e = 1000000007;
		for(int i = 3; i <= n; i++){
			tmp = t00 + t10;
			t00 = t10;
			t10 = t01;
			t01 = tmp % e;
		}
		System.out.println((t00+t01+t10)%e);
	}
}
0