結果

問題 No.557 点対称
ユーザー GrenacheGrenache
提出日時 2017-08-11 23:34:55
言語 Java19
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 3,623 ms
コンパイル使用メモリ 73,932 KB
実行使用メモリ 56,452 KB
最終ジャッジ日時 2023-08-02 23:54:40
合計ジャッジ時間 9,067 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,488 KB
testcase_01 AC 129 ms
55,636 KB
testcase_02 AC 130 ms
55,676 KB
testcase_03 AC 129 ms
55,680 KB
testcase_04 AC 131 ms
55,836 KB
testcase_05 AC 130 ms
55,660 KB
testcase_06 AC 127 ms
55,752 KB
testcase_07 AC 130 ms
55,768 KB
testcase_08 AC 128 ms
55,792 KB
testcase_09 AC 125 ms
55,500 KB
testcase_10 AC 129 ms
55,608 KB
testcase_11 AC 132 ms
55,448 KB
testcase_12 AC 130 ms
55,800 KB
testcase_13 AC 126 ms
55,720 KB
testcase_14 AC 128 ms
55,860 KB
testcase_15 AC 132 ms
55,784 KB
testcase_16 AC 128 ms
56,088 KB
testcase_17 AC 128 ms
55,872 KB
testcase_18 AC 125 ms
55,780 KB
testcase_19 AC 127 ms
55,708 KB
testcase_20 AC 127 ms
55,664 KB
testcase_21 AC 127 ms
55,704 KB
testcase_22 AC 129 ms
55,620 KB
testcase_23 AC 125 ms
55,956 KB
testcase_24 AC 126 ms
55,928 KB
testcase_25 AC 126 ms
55,412 KB
testcase_26 AC 127 ms
56,452 KB
testcase_27 AC 128 ms
55,428 KB
testcase_28 AC 128 ms
55,868 KB
testcase_29 AC 123 ms
55,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder557 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		final int MOD = 1_000_000_007;

		long n = sc.nextLong();

		if (n == 1) {
			pr.println(2);
		} else if (n % 2 == 0) {
			pr.println(modPow(5, n / 2 - 1, MOD) * 4 % MOD);
		} else {
			pr.println(3 * modPow(5, (n - 1) / 2 - 1, MOD) % MOD * 4 % MOD);
		}
	}

	private static long modPow(long a, long n, int MOD) {
		long loop = n;
		long ret = 1;
		long x = a;
		while (loop > 0) {
			if (loop % 2 == 1) {
				ret = ret * x % MOD;
			}
			x = x * x % MOD;
			loop /= 2;
		}

		return ret;
	}

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

		solve();

		pr.close();
		sc.close();
	}

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