結果
問題 | No.1310 量子アニーリング |
ユーザー |
👑 ![]() |
提出日時 | 2020-12-07 00:15:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 2,433 bytes |
コンパイル時間 | 2,269 ms |
コンパイル使用メモリ | 194,672 KB |
最終ジャッジ日時 | 2025-01-16 18:45:07 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
//#include<atcoder/all>//using namespace atcoder;#include<bits/stdc++.h>using namespace std;using LL=long long;using ULL=unsigned long long;#define rep(i,n) for(int i=0;i<(n);i++)template<ULL M>struct static_modint {ULL x;static_modint(ULL val = 0) : x(val) {}template<class intTy, enable_if_t<is_integral<intTy>::value&& is_unsigned<intTy>::value, void*> isUnsignedInt = nullptr>static static_modint mod_construct(intTy val) { return static_modint(val % M); }template<class intTy, enable_if_t<is_integral<intTy>::value&& is_signed<intTy>::value, void*> isSignedInt = nullptr>static static_modint mod_construct(intTy val) { LL buf = val % (LL)M; if (buf < 0) buf += M; return static_modint((ULL)buf); }static_modint operator-() const { if (x == 0) return 0; else return M - x; }static_modint& operator+=(static_modint r) { x += r.x; if (x >= M) x -= M; return *this; }static_modint operator+(static_modint r) const { static_modint res = x; return res += r; }static_modint& operator-=(static_modint r) { x += M - r.x; if (x >= M) x -= M; return *this; }static_modint operator-(static_modint r) const { static_modint res = x; return res -= r; }static_modint& operator*=(static_modint r) { x = x * r.x % M; return *this; }static_modint operator*(static_modint r) const { return static_modint(x * r.x % M); }static_modint pow(ULL r) const {if (r == 0) return static_modint(1);static_modint res = pow(r / 2);res *= res;if (r % 2) res *= *this;return res;}static_modint inv() const { return pow(M - 2); }static_modint& operator/=(static_modint r) { *this *= r.inv(); return *this; }static_modint operator/(static_modint r) const { return *this * r.inv(); }ULL& operator*() { return x; }const ULL& operator*() const { return x; }bool operator==(static_modint r) const { return x == *r; }bool operator!=(static_modint r) const { return x != *r; }};const ULL M=998244353;using MLL = static_modint<M>;const int Z=200000;MLL F[Z+1], I[Z+1], iF[Z+1];MLL P[Z+1];int main(){int N; cin>>N;F[0]=I[1]=iF[0]=1;for(int i=1; i<=N; i++) F[i]=F[i-1]*i;for(int i=2; i<=N; i++) I[i]=-(MLL(M/i)*I[M%i]);for(int i=1; i<=N; i++) iF[i]=iF[i-1]*I[i];P[0]=1;for(int i=1; i<=N; i++) P[i]=P[i-1]*2;vector<MLL> C(N+1); rep(i,N+1) C[i]=F[N]*iF[i]*iF[N-i];MLL ans=0;for(int i=0; i<=N; i+=2) ans+=C[i]*P[abs(N-2*i)]*2;cout<<*ans<<endl;return 0;}