結果

問題 No.557 点対称
ユーザー 37zigen37zigen
提出日時 2017-08-12 01:44:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 74,932 KB
実行使用メモリ 41,424 KB
最終ジャッジ日時 2024-04-21 00:32:33
合計ジャッジ時間 6,330 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
41,132 KB
testcase_01 AC 112 ms
40,284 KB
testcase_02 AC 109 ms
41,320 KB
testcase_03 AC 99 ms
39,732 KB
testcase_04 AC 110 ms
40,300 KB
testcase_05 AC 104 ms
40,144 KB
testcase_06 AC 114 ms
41,072 KB
testcase_07 AC 112 ms
41,076 KB
testcase_08 AC 113 ms
40,224 KB
testcase_09 AC 103 ms
40,056 KB
testcase_10 AC 108 ms
40,300 KB
testcase_11 AC 107 ms
39,896 KB
testcase_12 AC 103 ms
39,920 KB
testcase_13 AC 105 ms
39,872 KB
testcase_14 AC 117 ms
41,056 KB
testcase_15 AC 112 ms
41,080 KB
testcase_16 AC 103 ms
40,112 KB
testcase_17 AC 111 ms
39,896 KB
testcase_18 AC 98 ms
40,240 KB
testcase_19 AC 108 ms
39,780 KB
testcase_20 AC 104 ms
39,884 KB
testcase_21 AC 110 ms
41,424 KB
testcase_22 AC 103 ms
40,264 KB
testcase_23 AC 113 ms
41,240 KB
testcase_24 AC 115 ms
41,124 KB
testcase_25 AC 117 ms
41,128 KB
testcase_26 AC 116 ms
41,288 KB
testcase_27 AC 110 ms
40,296 KB
testcase_28 AC 115 ms
41,020 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	final long MODULO = 1_000_000_000 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		if (n == 1) {
			System.out.println(3);
			return;
		}
		if (n % 2 == 0) {
			System.out.println(4 * pow(5, n / 2 - 1) % MODULO);
		} else {
			System.out.println(4 * pow(5, n / 2 - 1) * 3 % MODULO);
		}
	}

	long pow(long a, long n) {
		long ret = 1;
		for (; n > 0; n >>= 1, a = (a * a) % MODULO) {
			if (n % 2 == 1) {
				ret = ret * a % MODULO;
			}
		}
		return ret;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
0