結果

問題 No.314 ケンケンパ
ユーザー tsunabittsunabit
提出日時 2020-03-29 15:31:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 177 ms / 1,000 ms
コード長 479 bytes
コンパイル時間 4,219 ms
コンパイル使用メモリ 72,388 KB
実行使用メモリ 58,284 KB
最終ジャッジ日時 2023-08-30 18:50:59
合計ジャッジ時間 8,485 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
57,708 KB
testcase_01 AC 126 ms
55,456 KB
testcase_02 AC 128 ms
57,548 KB
testcase_03 AC 128 ms
55,720 KB
testcase_04 AC 127 ms
55,300 KB
testcase_05 AC 125 ms
55,708 KB
testcase_06 AC 126 ms
55,736 KB
testcase_07 AC 126 ms
55,300 KB
testcase_08 AC 128 ms
55,512 KB
testcase_09 AC 128 ms
55,672 KB
testcase_10 AC 125 ms
55,500 KB
testcase_11 AC 126 ms
55,612 KB
testcase_12 AC 126 ms
55,600 KB
testcase_13 AC 128 ms
55,560 KB
testcase_14 AC 127 ms
55,516 KB
testcase_15 AC 127 ms
55,800 KB
testcase_16 AC 130 ms
55,676 KB
testcase_17 AC 140 ms
58,132 KB
testcase_18 AC 161 ms
58,284 KB
testcase_19 AC 177 ms
58,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No314 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = 1000000007;
		long a[] = {1, 0, 0}; // kp, pk, kk
		for(int i = 0; i < n; i++) {
			long t[] = {0, 0, 0};
			t[0] += (a[1] + a[2]) % m;
			t[1] += a[0] % m;
			t[2] += a[1] % m;
			a = t;
		}
		long ans = 0;
		for(int i = 0; i < 3; i++) ans += a[i];
		System.out.println(ans%m);
	}
}
0