結果

問題 No.1754 T-block Tiling
ユーザー AuroraAurora
提出日時 2021-11-20 14:58:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 1,647 ms
コンパイル使用メモリ 164,732 KB
実行使用メモリ 15,312 KB
最終ジャッジ日時 2023-09-02 09:18:08
合計ジャッジ時間 2,136 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
15,312 KB
testcase_01 AC 18 ms
15,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const long long int MAX = 510000;
const long long int MOD = 998244353;

long long int fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2;i<MAX;i++){
    fac[i] = fac[i-1]*i%MOD;
    inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i] = finv[i-1]*inv[i]%MOD;
  }
}

long long int COM(long long int n,long long int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

long long int modpow(long long int a,long long int n,long long int mod){
  long long int res = 1;
  while(n>0){
    if(n&1) res = res*a%mod;
    a = a*a%mod;
    n >>= 1;
  }
  return res;
}

int main(){
  COMinit();
  int T;
  cin >> T;
  for(int i=0;i<T;i++){
    int N;
    cin >> N;
    long long int ans = 0;
    for(int j=1;j<=N;j++){
      long long int plus = COM(N-1,j-1);
      plus *= modpow(2,j,MOD);
      plus %= MOD;
      ans += plus;
      ans %= MOD;
    }
    cout << ans << endl;
  }
}
0