結果

問題 No.8048 Order and Harmony
ユーザー heno239
提出日時 2019-04-01 23:19:14
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 917 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 119,680 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 13:53:12
合計ジャッジ時間 47,998 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 45 TLE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>

using namespace std;
typedef unsigned long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

ll mod_inverse(ll x) {
	ll n = mod - 2; ll ret = 1;
	while (n) {
		if (n & 1)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
void solve() {
	ll ans = 1;
	ll k; cin >> k;
	if (k % 2) {
		cout << 0 << endl; return;
	}
	else {
		k /= 2;
		ll h = 1;
		rep1(i, k) {
			h = h * i%mod;
		}
		ll s = 1;
		if (mod-2*k>k) {
			s = h;
			Rep1(i, k+1,2*k) {
				s = s * i%mod;
			}
		}
		else {
			for (int i = mod - 1; i > 2 * k; i--) {
				s = s * i%mod;
			}
			s = mod_inverse(s);
		}
		h = mod_inverse(h); h = h * h%mod;
		s = s * h%mod;
		cout << s << endl;
	}
}
int main() {
	solve();
	return 0;
}
0