結果

問題 No.523 LED
ユーザー GrenacheGrenache
提出日時 2017-06-02 22:36:08
言語 Java
(openjdk 23)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 3,689 ms
コンパイル使用メモリ 77,352 KB
実行使用メモリ 41,460 KB
最終ジャッジ日時 2024-09-21 22:32:55
合計ジャッジ時間 8,788 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder523 {

	private static Scanner sc;
	private static Printer pr;

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

		long inv2 = pow(2, MOD - 2);

		long ret = 1;
		for (int i = 1; i <= 2 * n; i++) {
			ret *= i;
			ret %= MOD;
		}

		for (int i = 0; i < n; i++) {
			ret *= inv2;
			ret %= MOD;
		}

		pr.println(ret);
	}

	private static final int MOD = 1_000_000_007;

	private static long pow(int a, int n) {
		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