結果

問題 No.420 mod2漸化式
ユーザー tactac
提出日時 2019-08-02 14:22:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 1,552 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 165,492 KB
実行使用メモリ 15,608 KB
最終ジャッジ日時 2023-09-18 18:12:57
合計ジャッジ時間 3,191 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
15,360 KB
testcase_01 AC 14 ms
15,488 KB
testcase_02 AC 14 ms
15,276 KB
testcase_03 AC 13 ms
15,300 KB
testcase_04 AC 13 ms
15,488 KB
testcase_05 AC 13 ms
15,344 KB
testcase_06 AC 13 ms
15,304 KB
testcase_07 AC 14 ms
15,328 KB
testcase_08 AC 14 ms
15,408 KB
testcase_09 AC 13 ms
15,300 KB
testcase_10 AC 14 ms
15,292 KB
testcase_11 AC 14 ms
15,332 KB
testcase_12 AC 13 ms
15,328 KB
testcase_13 AC 14 ms
15,380 KB
testcase_14 AC 14 ms
15,420 KB
testcase_15 AC 14 ms
15,276 KB
testcase_16 AC 13 ms
15,344 KB
testcase_17 AC 13 ms
15,356 KB
testcase_18 AC 14 ms
15,300 KB
testcase_19 AC 13 ms
15,296 KB
testcase_20 AC 13 ms
15,292 KB
testcase_21 AC 13 ms
15,504 KB
testcase_22 AC 14 ms
15,296 KB
testcase_23 AC 14 ms
15,276 KB
testcase_24 AC 14 ms
15,360 KB
testcase_25 AC 14 ms
15,332 KB
testcase_26 AC 14 ms
15,352 KB
testcase_27 AC 14 ms
15,328 KB
testcase_28 AC 13 ms
15,492 KB
testcase_29 AC 14 ms
15,404 KB
testcase_30 AC 14 ms
15,356 KB
testcase_31 AC 14 ms
15,364 KB
testcase_32 AC 14 ms
15,600 KB
testcase_33 AC 14 ms
15,292 KB
testcase_34 AC 13 ms
15,608 KB
testcase_35 AC 14 ms
15,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
string str;
int n, c, d;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 2^31 - 1
// = 2^30 + 2^29 + 2^28 + ... + 2^0
// 各々のbitは30Cx-1回1になる


// 解説ac
// 具体的に書き出してみるべきだった
int main() {
    COMinit();
    int x;
    cin >> x;
    if (x > 31) { out(0 << " " << 0); return 0; }
    
    out(COM(31, x) << " " << (ll)(pow(2, 31) - 1) * COM(30, x - 1));
    
}
0