結果

問題 No.1100 Boxes
ユーザー cureskolcureskol
提出日時 2022-07-15 21:28:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 200,348 KB
実行使用メモリ 42,676 KB
最終ジャッジ日時 2023-09-10 00:35:34
合計ジャッジ時間 7,421 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
42,676 KB
testcase_01 AC 59 ms
42,640 KB
testcase_02 AC 58 ms
42,400 KB
testcase_03 AC 58 ms
42,452 KB
testcase_04 AC 58 ms
42,356 KB
testcase_05 AC 58 ms
42,428 KB
testcase_06 AC 57 ms
42,512 KB
testcase_07 AC 58 ms
42,400 KB
testcase_08 AC 58 ms
42,396 KB
testcase_09 AC 58 ms
42,532 KB
testcase_10 AC 58 ms
42,412 KB
testcase_11 AC 58 ms
42,424 KB
testcase_12 AC 58 ms
42,424 KB
testcase_13 AC 58 ms
42,428 KB
testcase_14 AC 59 ms
42,360 KB
testcase_15 AC 58 ms
42,640 KB
testcase_16 AC 58 ms
42,640 KB
testcase_17 AC 58 ms
42,404 KB
testcase_18 AC 58 ms
42,360 KB
testcase_19 AC 58 ms
42,476 KB
testcase_20 AC 59 ms
42,396 KB
testcase_21 AC 64 ms
42,356 KB
testcase_22 AC 70 ms
42,372 KB
testcase_23 AC 64 ms
42,360 KB
testcase_24 AC 65 ms
42,416 KB
testcase_25 AC 67 ms
42,364 KB
testcase_26 AC 74 ms
42,448 KB
testcase_27 AC 71 ms
42,404 KB
testcase_28 AC 61 ms
42,404 KB
testcase_29 AC 73 ms
42,452 KB
testcase_30 AC 70 ms
42,356 KB
testcase_31 AC 64 ms
42,368 KB
testcase_32 AC 70 ms
42,412 KB
testcase_33 AC 77 ms
42,368 KB
testcase_34 AC 77 ms
42,360 KB
testcase_35 AC 58 ms
42,356 KB
testcase_36 AC 67 ms
42,560 KB
testcase_37 AC 58 ms
42,452 KB
testcase_38 AC 65 ms
42,368 KB
testcase_39 AC 76 ms
42,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)

#include <atcoder/modint>
using namespace atcoder;
using mint=modint998244353;
ostream& operator<<(ostream &os,mint a){os<<a.val();return os;}
istream& operator>>(istream &is,mint &a){
  long long b;is>>b;a=b;
  return is;
}

const int SIZE=5000000;
mint Factorial[SIZE],Finverse[SIZE];
void Cinit(){
  Factorial[0]=mint(1);
  for(int i=1;i<SIZE;i++)Factorial[i]=Factorial[i-1]*mint(i);
  Finverse[SIZE-1]=Factorial[SIZE-1].inv();
  for(int i=SIZE-2;i>=0;i--)Finverse[i]=mint(i+1)*Finverse[i+1];
}
mint nCk(int n,int k){
  if(Factorial[0]==0)Cinit();
  if(n<k)return 0;
  return Factorial[n]*Finverse[n-k]*Finverse[k];
}

int main(){
  int n,k;cin>>n>>k;
  mint ans=mint(k).pow(n);
  REP(i,k+1)ans-=mint(k-i).pow(n)*mint(-2).pow(i)*nCk(k,i);
  ans/=2;
  cout<<ans<<endl;
}
0