結果
問題 | No.1754 T-block Tiling |
ユーザー |
![]() |
提出日時 | 2021-11-20 14:01:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,581 bytes |
コンパイル時間 | 2,244 ms |
コンパイル使用メモリ | 169,820 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 14:54:18 |
合計ジャッジ時間 | 2,336 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;const int INF = 1e9;const ll inf = 1LL<<60;template<int MOD> struct ModInt {static const int Mod = MOD; unsigned x; ModInt() : x(0) { }ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }int get() const { return (int)x; }ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }ModInt operator+(ModInt that) const { return ModInt(*this) += that; }ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }return ModInt(u); }bool operator==(ModInt that) const { return x == that.x; }bool operator!=(ModInt that) const { return x != that.x; }ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }};template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }typedef ModInt<998244353> mint;template<typename T>struct Combination {private:int sz;vector<T> F, F_;public:Combination(int sz) : sz(sz), F(sz+1), F_(sz+1) {F[0] = 1;for(int i = 0; i < sz; ++i) F[i+1] = F[i]*(i+1);F_.back() = (T)1/F.back();for(int i = sz-1; i >= 0; --i) F_[i] = F_[i+1]*(i+1);}T C(int n, int k){assert(n <= sz);if(n < 0 or k > n) return (T)0;return F[n]*F_[k]*F_[n-k];}T P(int n, int k){assert(n <= sz);if(n < 0 or k > n) return (T)0;return F[n]*F_[n-k];}};int main() {int t; cin >> t;Combination<mint> comb(1000);while (t--) {int n; cin >> n;mint ans = mint(0);for (int i=n; i>=1; i--) {int k = n-i;mint tmp = comb.C(k+(i-1), k);mint q = mint(2)^(i);ans += q*tmp;}cout << ans << endl;}}