結果
| 問題 |
No.8048 Order and Harmony
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2019-04-01 22:06:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,267 bytes |
| コンパイル時間 | 1,610 ms |
| コンパイル使用メモリ | 167,248 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-11-27 02:58:30 |
| 合計ジャッジ時間 | 63,635 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 TLE * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
lint K;
constexpr lint MOD = 1000000007;
// Solve ax+by=gcd(a, b)
lint extgcd(lint a, lint b, lint &x, lint &y)
{
lint d = a;
if (b != 0) d = extgcd(b, a % b, y, x), y -= (a / b) * x;
else x = 1, y = 0;
return d;
}
// Calc a^(-1) (MOD m)
lint mod_inverse(lint a, lint m)
{
lint x, y;
extgcd(a, m, x, y);
return (m + x % m) % m;
}
int main()
{
cin >> K;
lint ans, ans2;
if (K % 2) cout << 0 << endl;
else
{
ans = 1;
REP(i, K / 2) ans = (ans * (i + 1)) % MOD;
ans2 = ans;
REP(i, K / 2) ans = (ans * (i + 1 + K / 2)) % MOD;
dbg(ans2);
dbg(ans);
cout << mod_inverse(ans2, MOD) * mod_inverse(ans2, MOD) % MOD * ans % MOD << endl;
}
}
hitonanode