結果

問題 No.523 LED
ユーザー ぴろずぴろず
提出日時 2017-06-02 22:46:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 411 ms / 2,000 ms
コード長 814 bytes
コンパイル時間 4,074 ms
コンパイル使用メモリ 77,348 KB
実行使用メモリ 57,688 KB
最終ジャッジ日時 2023-10-21 22:08:05
合計ジャッジ時間 7,994 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
57,512 KB
testcase_01 AC 102 ms
56,200 KB
testcase_02 AC 106 ms
56,136 KB
testcase_03 AC 100 ms
56,180 KB
testcase_04 AC 111 ms
55,440 KB
testcase_05 AC 411 ms
57,516 KB
testcase_06 AC 103 ms
56,160 KB
testcase_07 AC 113 ms
57,328 KB
testcase_08 AC 113 ms
57,320 KB
testcase_09 AC 126 ms
57,688 KB
testcase_10 AC 116 ms
57,208 KB
testcase_11 AC 105 ms
56,144 KB
testcase_12 AC 112 ms
57,048 KB
testcase_13 AC 163 ms
55,976 KB
testcase_14 AC 115 ms
57,020 KB
testcase_15 AC 112 ms
55,320 KB
testcase_16 AC 113 ms
57,404 KB
testcase_17 AC 105 ms
56,328 KB
testcase_18 AC 404 ms
56,836 KB
testcase_19 AC 232 ms
57,592 KB
testcase_20 AC 213 ms
57,300 KB
testcase_21 AC 341 ms
57,596 KB
testcase_22 AC 360 ms
56,224 KB
testcase_23 AC 362 ms
57,384 KB
testcase_24 AC 114 ms
56,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no523;

import java.util.Scanner;

public class Main {
	public static long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long fact = 1;
		for(int i=1;i<=2*n;i++) {
			fact = fact * i % MOD;
		}
		long ans = fact * pow(inverse(2, MOD), n, MOD) % MOD;
		System.out.println(ans);
	}
	public static long pow(long a,long n,long mod) {
		long res = 1;
		while(n > 0) {
			if ((n & 1) > 0) {
				res = (res * a) % mod;
			}
			a = (a * a) % mod;
			n/=2;
		}
		return res;
	}
	public static long inverse(long a,long mod) {
		long b = mod, u = 1, v = 0;
		while(b > 0) {
			long temp;
			long t = a / b;
			a -= t * b;
			temp = a; a = b; b = temp;
			u -= t * v;
			temp = u; u = v; v = temp;
		}
		return (u % mod + mod) % mod;
	}
}
0