結果

問題 No.727 仲介人moko
ユーザー bal4ubal4u
提出日時 2019-08-01 06:26:57
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 804 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 30,044 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 17:16:21
合計ジャッジ時間 2,011 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 0 ms
4,380 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 10 ms
4,380 KB
testcase_20 AC 6 ms
4,376 KB
testcase_21 AC 3 ms
4,384 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 12 ms
4,376 KB
testcase_24 AC 12 ms
4,380 KB
testcase_25 AC 8 ms
4,380 KB
testcase_26 AC 10 ms
4,376 KB
testcase_27 AC 8 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.727 仲介人moko
// 2019.8.1 bal4u

#include <stdio.h>

typedef long long ll;
#define MOD 1000000007

int modpow(int x, int p) {
	int r = 1;
	while (p) {
		if (p & 1) r = (ll)r * x % MOD;
		x = (ll)x * x % MOD;
		p >>= 1;
	}
	return r;
}

int extended_gcd(int a, int b, int *x, int *y) {
	int d;
	if (b == 0) { *x = 1; *y = 0; return a; }
	d = extended_gcd(b, a % b, y, x);
	*y -= a / b * (*x);
	return d;
}

int inverse(int a) {
    int x, y;
    extended_gcd(a, MOD, &x, &y);
	return (x + MOD) % MOD;
}

int main()
{
	int i, N, a, ans, an2;

	scanf("%d", &N);
	a = inverse(modpow(2, N));
	ans = 1; for (i = 2; i <= N; i++) ans = (ll)ans * i % MOD;
	N <<= 1; for (an2 = ans; i <= N; i++) an2 = (ll)an2 * i % MOD;
	ans = (ll)ans * an2 % MOD * a % MOD;
	printf("%d\n", ans);
	return 0;
}
0