結果

問題 No.1100 Boxes
ユーザー SSRSSSRS
提出日時 2020-06-26 08:58:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 169,480 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 23:28:16
合計ジャッジ時間 4,868 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 19 ms
4,376 KB
testcase_22 AC 40 ms
4,376 KB
testcase_23 AC 20 ms
4,380 KB
testcase_24 AC 24 ms
4,380 KB
testcase_25 AC 29 ms
4,376 KB
testcase_26 AC 49 ms
4,380 KB
testcase_27 AC 40 ms
4,376 KB
testcase_28 AC 12 ms
4,376 KB
testcase_29 AC 45 ms
4,380 KB
testcase_30 AC 37 ms
4,376 KB
testcase_31 AC 18 ms
4,376 KB
testcase_32 AC 33 ms
4,384 KB
testcase_33 AC 54 ms
4,376 KB
testcase_34 AC 54 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 43 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 23 ms
4,380 KB
testcase_39 AC 51 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return (ans + MOD) % MOD;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
vector<long long> mf;
long long modfact(int n){
  if (n < mf.size()){
    return mf[n];
  } else {
    if (mf.empty()){
      mf.push_back(1);
    }
    for (int i = mf.size(); i <= n; i++){
      long long next = mf.back() * i % MOD;
      mf.push_back(next);
    }
    return mf.back();
  }
}
long long modbinom(int a, int b){
  return modfact(a) * modinv(modfact(b)) % MOD * modinv(modfact(a - b)) % MOD;
}
int main(){
  int N, K;
  cin >> N >> K;
  long long ans = 0;
  for (int i = 1; i <= K; i++){
    ans += modbinom(K, i) * modpow(-2, i - 1) % MOD * modpow(K - i, N) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}
0