結果

問題 No.2206 Popcount Sum 2
ユーザー vjudge1
提出日時 2025-08-01 21:12:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,210 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 195,132 KB
実行使用メモリ 13,344 KB
最終ジャッジ日時 2025-08-01 21:12:53
合計ジャッジ時間 9,723 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
using namespace std;

const int maxn = 2e5 + 5;
const int mod = 998244353;
int n, ifac[maxn], fac[maxn], pw[maxn], m;

void Add(int &x, int y){((x += y) >= mod) && (x -= mod);}

int qpow(int x, int y){int sum = 1; for(; y; y >>= 1, x = 1ll * x * x % mod) if(y & 1) sum = 1ll * sum * x % mod; return sum;}
void init(){
    int N = 2e5;
    fac[0] = 1; for(int i = 1; i <= N; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
    ifac[N] = qpow(fac[N], mod - 2); for(int i = N; i; i --) ifac[i - 1] = 1ll * ifac[i] * i % mod;
    pw[0] = 1; for(int i = 1; i <= N; i++) pw[i] = 2ll * pw[i - 1] % mod;
}

int C(int x, int y){return x < 0 || y < 0 || x < y ? 0 : 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;}

void solve(){
    cin >> n >> m;
    int ans = 0, sum = 0;
    for(int i = 0; i <= m - 1; i++) Add(sum, C(n - 1, i));
    for(int i = 0; i < n; i++){
        Add(ans, 1ll * pw[i] * sum % mod);
    }
    cout << ans << '\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    init();
    int t; cin >> t; while(t--) solve();

    return 0;
}
0