結果

問題 No.1310 量子アニーリング
ユーザー nemutainemutai
提出日時 2023-03-24 10:57:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,053 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 170,860 KB
実行使用メモリ 8,020 KB
最終ジャッジ日時 2023-10-18 20:01:13
合計ジャッジ時間 2,998 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 17 ms
4,588 KB
testcase_14 AC 23 ms
5,116 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 44 ms
6,700 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 12 ms
4,348 KB
testcase_21 AC 7 ms
4,348 KB
testcase_22 AC 59 ms
8,020 KB
testcase_23 AC 16 ms
4,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0