結果

問題 No.1533 Don't be Negative!
ユーザー googol_S0googol_S0
提出日時 2021-05-21 23:51:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 944 bytes
コンパイル時間 4,535 ms
コンパイル使用メモリ 257,028 KB
実行使用メモリ 5,852 KB
最終ジャッジ日時 2024-04-19 09:41:30
合計ジャッジ時間 83,501 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using mint=modint998244353;
vector<mint> g1(2,1);
vector<mint> g2(2,1);
vector<mint> inv(2,1);
const int mod=998244353;
mint cmb(int a,int b){
  if((b<0)&&(b>a)){
    return 0;
  }
  return g1[a]*g2[b]*g2[a-b];
}
int main(){
  inv[0]=0;
  int n,m;
  cin>>n>>m;
  mint N,M;
  N=mint::raw(n);
  M=mint::raw(m);
  mint ANS=0;
  for(int i=2;i<n*(m+1)+6;i++){
    g1.push_back(g1[i-1]*i);
    inv.push_back(-inv[mod%i]*(mod/i));
    g2.push_back((g2[i-1]*inv[i]));
  }
  mint V=(2*M+1).pow(n),W=(2*M+1).pow(mod-2),U=1;
  mint A,Y;
  int X,Z;
  for(int K=1;K<=n;K++){
    V*=W;
    U*=(2*M+1);
    A=0;
    X=0;
    Y=1;
    Z=0;
    while(X<=K){
      if(Z>m*K){
        break;
      }
      A+=cmb(m*K-Z+K-1,m*K-Z)*Y*cmb(K,X);
      X++;
      Z+=2*m+1;
      Y=-Y;
    }
    ANS+=(U-A)*V*(N-K+1);
  }
  cout<<(ANS*(mint::raw(2).pow(mod-2))).val()<<endl;
}
0