結果
問題 |
No.1310 量子アニーリング
|
ユーザー |
![]() |
提出日時 | 2023-03-24 10:57:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,053 bytes |
コンパイル時間 | 1,486 ms |
コンパイル使用メモリ | 170,372 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-09-18 15:59:14 |
合計ジャッジ時間 | 2,712 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 8 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define all(v) v.begin(),v.end() using ll = long long; using ull = unsigned long long; using vll=vector<ll>; using vvll = vector<vector<ll>>; ll mod=998244353; vector<ll> fact,invfact,inv; void init(ll N){ fact.resize(N+5); inv.resize(N+5); invfact.resize(N+5); fact[0]=1;fact[1]=1; invfact[0]=1;invfact[1]=1; inv[0]=1;inv[1]=1; for(int i=2;i<N+3;i++){ fact[i]=fact[i-1]*i%mod; inv[i]=mod-inv[mod%i]*(mod/i)%mod; invfact[i] = invfact[i-1]*inv[i]%mod; } } ll nCk(ll n,ll x){ return fact[n]*invfact[n-x]%mod*invfact[x]%mod; } ll powmod(ll x,ll n,ll m){ ll res=1; while(n>0){ if(n&1) res*=x; x*=x; res%=m; x%=m; n>>=1; } return res; } int main(){ ll N; cin>>N; init(N); ll ans=0; ll n=N; for(int i=N;i>N/2;i--){ ans+=powmod(2,n,mod)*nCk(N,i)*2; ans%=mod; n-=2; } if(N%2==0){ ans+=nCk(N,N/2); } cout << ans%mod << endl; }