結果

問題 No.420 mod2漸化式
ユーザー 佐藤淳平
提出日時 2019-09-10 14:48:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 569 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 158,076 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-02 16:15:28
合計ジャッジ時間 2,614 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

i64 comb(i64, i64);
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    i64 x; cin >> x;
    if (x == 0) {
        cout << 1 << " " << 0 << endl;
        return 0;
    }
    if (x > 31) {
        cout << 0 << " " << 0 << endl;
        return 0;
    }

    cout << comb(31, x) << " " << 2147483647 * comb(30, x - 1) << endl;
    return 0;
}

i64 comb(i64 p, i64 q) {
    i64 ret = 1;
    for (int i = 1; i <= q; i++) {
        ret = ret * (p - i + 1) / i;
    }
    return ret;
}
0