結果

問題 No.1856 Mex Sum 2
ユーザー ytqm3ytqm3
提出日時 2022-02-25 23:07:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 413 ms / 3,000 ms
コード長 1,006 bytes
コンパイル時間 4,531 ms
コンパイル使用メモリ 267,872 KB
実行使用メモリ 26,852 KB
最終ジャッジ日時 2023-09-16 18:30:21
合計ジャッジ時間 19,602 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
26,456 KB
testcase_01 AC 38 ms
26,364 KB
testcase_02 AC 39 ms
26,224 KB
testcase_03 AC 38 ms
26,400 KB
testcase_04 AC 38 ms
26,252 KB
testcase_05 AC 37 ms
26,228 KB
testcase_06 AC 39 ms
26,388 KB
testcase_07 AC 39 ms
26,268 KB
testcase_08 AC 38 ms
26,252 KB
testcase_09 AC 39 ms
26,292 KB
testcase_10 AC 38 ms
26,324 KB
testcase_11 AC 39 ms
26,264 KB
testcase_12 AC 39 ms
26,408 KB
testcase_13 AC 38 ms
26,296 KB
testcase_14 AC 39 ms
26,412 KB
testcase_15 AC 38 ms
26,296 KB
testcase_16 AC 38 ms
26,400 KB
testcase_17 AC 38 ms
26,472 KB
testcase_18 AC 39 ms
26,336 KB
testcase_19 AC 39 ms
26,400 KB
testcase_20 AC 38 ms
26,196 KB
testcase_21 AC 38 ms
26,252 KB
testcase_22 AC 39 ms
26,260 KB
testcase_23 AC 37 ms
26,396 KB
testcase_24 AC 38 ms
26,404 KB
testcase_25 AC 39 ms
26,320 KB
testcase_26 AC 37 ms
26,468 KB
testcase_27 AC 38 ms
26,524 KB
testcase_28 AC 37 ms
26,472 KB
testcase_29 AC 119 ms
26,800 KB
testcase_30 AC 79 ms
26,732 KB
testcase_31 AC 116 ms
26,648 KB
testcase_32 AC 157 ms
26,816 KB
testcase_33 AC 163 ms
26,688 KB
testcase_34 AC 116 ms
26,660 KB
testcase_35 AC 84 ms
26,852 KB
testcase_36 AC 58 ms
26,724 KB
testcase_37 AC 113 ms
26,360 KB
testcase_38 AC 52 ms
26,760 KB
testcase_39 AC 39 ms
26,740 KB
testcase_40 AC 39 ms
26,764 KB
testcase_41 AC 40 ms
26,660 KB
testcase_42 AC 395 ms
26,824 KB
testcase_43 AC 356 ms
26,796 KB
testcase_44 AC 370 ms
26,748 KB
testcase_45 AC 397 ms
26,480 KB
testcase_46 AC 353 ms
26,736 KB
testcase_47 AC 378 ms
26,804 KB
testcase_48 AC 402 ms
26,736 KB
testcase_49 AC 401 ms
26,744 KB
testcase_50 AC 327 ms
26,732 KB
testcase_51 AC 413 ms
26,800 KB
testcase_52 AC 411 ms
26,660 KB
testcase_53 AC 410 ms
26,716 KB
testcase_54 AC 407 ms
26,764 KB
testcase_55 AC 404 ms
26,740 KB
testcase_56 AC 402 ms
26,828 KB
testcase_57 AC 409 ms
26,732 KB
testcase_58 AC 409 ms
26,732 KB
testcase_59 AC 401 ms
26,688 KB
testcase_60 AC 400 ms
26,716 KB
testcase_61 AC 406 ms
26,688 KB
testcase_62 AC 407 ms
26,788 KB
testcase_63 AC 406 ms
26,760 KB
testcase_64 AC 402 ms
26,692 KB
testcase_65 AC 407 ms
26,744 KB
testcase_66 AC 413 ms
26,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
typedef uint64_t u64;
typedef int64_t i64;
template<u64 mod> using modint=atcoder::static_modint<mod>;
using namespace std;

template<typename T> struct comb{
  vector<T> dat,idat;
  comb(int mx=3000000):dat(mx+1,1),idat(mx+1,1){
    for(int i=1;i<=mx;++i){
      dat[i]=dat[i-1]*i;
    }
    idat[mx]/=dat[mx];
    for(int i=mx;i>0;--i){
      idat[i-1]=idat[i]*i;
    }
  }
  T operator()(int n,int k){
    if(n<0||k<0||n<k){
      return 0;
    }
    return dat[n]*idat[k]*idat[n-k];
  }
};

int main(){
  constexpr u64 mod=998244353;
  typedef modint<mod> mint;
  comb<mint> C;
  int N,M;
  cin>>N>>M;
  vector<mint> f(N+1);
  for(int i=0;i<=N;++i){
    f[i]=(mint(2).pow(i)-1)*C.idat[i];
  }
  vector<mint> g(N+1);
  g[0]=1;
  mint ans=0;
  for(int i=0;i<min(N,M+1);++i){
  	g=atcoder::convolution(f,g);
  	g.resize(N+1);
  	mint now=1;
  	for(int j=N;j>i;--j){
  		ans+=C.dat[N]*C.idat[N-j]*now*g[j];
  		now*=2*(M-i);
  	}
  }
  cout<<ans.val()<<endl;
}
0