結果

問題 No.986 Present
ユーザー kyort0nkyort0n
提出日時 2020-02-11 16:05:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 292 ms / 2,000 ms
コード長 2,252 bytes
コンパイル時間 1,820 ms
コンパイル使用メモリ 170,208 KB
実行使用メモリ 237,808 KB
最終ジャッジ日時 2024-04-08 15:31:26
合計ジャッジ時間 10,069 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
237,808 KB
testcase_01 AC 175 ms
237,808 KB
testcase_02 AC 175 ms
237,808 KB
testcase_03 AC 225 ms
237,808 KB
testcase_04 AC 177 ms
237,808 KB
testcase_05 AC 222 ms
237,808 KB
testcase_06 AC 202 ms
237,808 KB
testcase_07 AC 178 ms
237,808 KB
testcase_08 AC 194 ms
237,808 KB
testcase_09 AC 240 ms
237,808 KB
testcase_10 AC 177 ms
237,808 KB
testcase_11 AC 215 ms
237,808 KB
testcase_12 AC 209 ms
237,808 KB
testcase_13 AC 178 ms
237,808 KB
testcase_14 AC 190 ms
237,808 KB
testcase_15 AC 286 ms
237,808 KB
testcase_16 AC 184 ms
237,808 KB
testcase_17 AC 249 ms
237,808 KB
testcase_18 AC 218 ms
237,808 KB
testcase_19 AC 198 ms
237,808 KB
testcase_20 AC 187 ms
237,808 KB
testcase_21 AC 274 ms
237,808 KB
testcase_22 AC 264 ms
237,808 KB
testcase_23 AC 211 ms
237,808 KB
testcase_24 AC 292 ms
237,808 KB
testcase_25 AC 193 ms
237,808 KB
testcase_26 AC 285 ms
237,808 KB
testcase_27 AC 248 ms
237,808 KB
testcase_28 AC 176 ms
237,808 KB
testcase_29 AC 174 ms
237,808 KB
testcase_30 AC 173 ms
237,808 KB
testcase_31 AC 174 ms
237,808 KB
testcase_32 AC 174 ms
237,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//つぶあん つぶす
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const ll mod = 998244353;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll N, M;
ll ans[3];

void ANSWER() {
    for(int i = 0; i < 3; i++) {
        if(i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    cin >> N >> M;
    ans[0] = beki(2, N);
    ans[1] = 1;
    ll factor = 1;
    for(int i = 0; i < N; i++) {
        ans[1] *= beki(2, M - i) - 1;
        ans[1] %= mod;
        ans[1] *= beki(2, i);
        ans[1] %= mod;
        factor *= beki(2, N - i) - 1;
        factor %= mod;
        factor *= beki(2, i);
        factor %= mod;
    }
    ans[1] *= FactorialInv[N];
    ans[1] %= mod;
    factor *= FactorialInv[N];
    factor %= mod;
    ans[2] = ans[1] * beki(factor, mod - 2) % mod;
    ANSWER();
    return 0;
}
0