結果

問題 No.3048 Order and Harmony
ユーザー SumitacchanSumitacchan
提出日時 2019-04-01 23:04:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 3,580 bytes
コンパイル時間 1,444 ms
コンパイル使用メモリ 165,060 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 02:10:52
合計ジャッジ時間 8,014 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 194 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 207 ms
4,380 KB
testcase_26 AC 261 ms
4,376 KB
testcase_27 AC 245 ms
4,380 KB
testcase_28 AC 16 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 10 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 194 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 54 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 49 ms
4,380 KB
testcase_37 AC 268 ms
4,380 KB
testcase_38 AC 44 ms
4,380 KB
testcase_39 AC 217 ms
4,376 KB
testcase_40 AC 176 ms
4,380 KB
testcase_41 AC 231 ms
4,380 KB
testcase_42 AC 223 ms
4,384 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 218 ms
4,380 KB
testcase_45 AC 50 ms
4,376 KB
testcase_46 AC 147 ms
4,376 KB
testcase_47 AC 139 ms
4,380 KB
testcase_48 AC 82 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 111 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 295 ms
4,380 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 260 ms
4,380 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 2 ms
4,376 KB
testcase_60 AC 33 ms
4,384 KB
testcase_61 AC 202 ms
4,376 KB
testcase_62 AC 66 ms
4,380 KB
testcase_63 AC 1 ms
4,376 KB
testcase_64 AC 329 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
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);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

int memo[101] = {1,682498929,491101308,76479948,723816384,67347853,27368307,625544428,199888908,888050723,927880474,281863274,661224977,623534362,970055531,261384175,195888993,66404266,547665832,109838563,933245637,724691727,368925948,268838846,136026497,112390913,135498044,217544623,419363534,500780548,668123525,128487469,30977140,522049725,309058615,386027524,189239124,148528617,940567523,917084264,429277690,996164327,358655417,568392357,780072518,462639908,275105629,909210595,99199382,703397904,733333339,97830135,608823837,256141983,141827977,696628828,637939935,811575797,848924691,131772368,724464507,272814771,326159309,456152084,903466878,92255682,769795511,373745190,606241871,825871994,957939114,435887178,852304035,663307737,375297772,217598709,624148346,671734977,624500515,748510389,203191898,423951674,629786193,672850561,814362881,823845496,116667533,256473217,627655552,245795606,586445753,172114298,193781724,778983779,83868974,315103615,965785236,492741665,377329025,847549272,698611116};
int D = 10000000;

int fact(int N){
    int c = memo[N / D];
    int s = (N / D) * D;
    FOR(i, s + 1, N + 1) Mult(c, i);
    return c;
}

int modpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

signed main(){

    int N; cin >> N;
    /*
    int c = 1;
    ofstream ofs("memo.txt");
    ofs << "1,";
    FOR(i, 1, 1000000001){
        Mult(c, i);
        if(i % 10000000 == 0){
            ofs << c << ",";
        }
    }*/

    int ans;
    if(N % 2) ans = 0;
    else{
        int a, b;
        int c = 1;
        a = fact(N / 2);
        b = fact(N);
        a = modpow(a, mod - 2, mod);
        Mult(b, a);
        Mult(b, a);
        ans = b;
    }
    cout << ans << endl;

    return 0;
}
0