結果

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<queue>
#include<array>
#include<unordered_set>
#include<iomanip>
#if defined FIO
auto FI=freopen("1.in","r",stdin);
auto FO=freopen("1.out","w",stdout);
#endif
#if defined BUG
#define bug(x...) ({x;void();})
#else
#define bug(x...) ({})
#endif
#define LL long long
#define pb push_back
#define vec vector
#define arr array
#define SIZ(x) (int)(x).size()
#define ALL(x) begin(x),end(x)
#define RNG(x,l,r) &(x)[l],1+&(x)[r]
#define rep(i,l,r) for(int i=(l),i##_=(r);i<=i##_;i++)
#define per(i,l,r) for(int i=(l),i##_=(r);i>=i##_;i--)
#define inline inline __attribute__((always_inline))
template<class U,class V>constexpr inline void tomin(U&x,V&&y)noexcept{if(y<x)x=y;}
template<class U,class V>constexpr inline void tomax(U&x,V&&y)noexcept{if(y>x)x=y;}
struct FIN{
    static constexpr signed S_=1<<20;char B_[S_],*H_,*T_;
    #define getchar() (H_==T_&&(T_=(H_=B_)+fread(B_,1,S_,stdin),H_==T_)?EOF:*H_++)
    inline bool isspace(char m){return m==' '||m=='\n'||m=='\r';}
    inline void fin(char&m)noexcept{do{}while(isspace(m=getchar()));}
    template<class T>inline void fin(T&x)noexcept{char m=0,f=0;do if(m==45)f=1;while(m=getchar(),m<48||m>57);x=0;do x=x*10+(m^48);while(m=getchar(),m>=48&&m<=57);if(f)x=-x;}
    template<class T>inline FIN& operator>>(T&x)noexcept{fin(x);return *this;}
};
struct FOUT{
    inline void fout(char m)noexcept{putchar(m);}
    inline void fout(const char*s)noexcept{printf("%s",s);}
    template<class T>inline void fout(T x)noexcept{char d[40],l=-1;if(x<0)x=-x,putchar(45);do d[(signed)++l]=char((x%10)^48);while(x/=10);do putchar(d[(signed)l]);while(~--l);}
    template<class T>inline FOUT& operator<<(T x)noexcept{fout(x);return *this;}
};
using namespace std;namespace __{
// FIN cin; FOUT cout;
auto SYNC=cin.tie(0)->sync_with_stdio(0);

#define clear()
constexpr int N=2e5+5,P=998244353;
inline int fpw(int a,int b,int r=1){
    for(; b; a = 1LL * a * a % P, b>>=1) if(b&1) r = 1LL * r * a % P; return r;}

int fac[N],invfac[N];
inline void init(int n){
    fac[0]=1; rep(i,1,n) fac[i] = 1LL * fac[i-1] * i % P;
    invfac[n] = fpw(fac[n], P-2); per(i,n,1) invfac[i-1] = 1LL * invfac[i] * i % P;
}
inline int binom(int a,int b){
    if(a<b) return 0;
    return 1LL * fac[a] * invfac[b] % P * invfac[a-b] % P;
}

void main(){
    init(2e5);
    vec<int> pw2(2e5+5); pw2[0]=1;
    rep(i,1,2e5) pw2[i] = pw2[i-1] * 2 % P;
    signed CSE=0; for(cin>>CSE; CSE--; clear())
[&](){
    int n,m; cin>>n>>m;
    LL sum=0;
    rep(k,0,m-1) sum+=binom(n-1,k);
    cout<<(sum%P) * (pw2[n] - 1 + P) % P<<'\n';
}();}}
signed main(){__::main();}
0