結果

問題 No.1310 量子アニーリング
ユーザー HaaHaa
提出日時 2020-12-07 04:01:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 168,048 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 15:55:09
合計ジャッジ時間 2,630 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
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 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 12 ms
4,348 KB
testcase_15 AC 15 ms
4,348 KB
testcase_16 AC 16 ms
4,348 KB
testcase_17 AC 22 ms
4,348 KB
testcase_18 AC 29 ms
4,348 KB
testcase_19 AC 14 ms
4,348 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 29 ms
4,348 KB
testcase_23 AC 9 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=1e18;

ll power(ll x, ll y){
	x%=MOD;
	ll ret=1;
	while(y){
		if(y&1) ret=ret*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return ret;
}

ll divid(ll x, ll y){
	x%=MOD;
	return x*power(y,MOD-2)%MOD;
}

int main(){
    int n; cin >> n;
    ll a=1, b=1, ans=0;
    ans+=2*power(2,n)%MOD;
    for(int i=2;i<=n;i+=2){
        a=(a*(n-i+1))%MOD*(n-i+2)%MOD;
        b=(b*i)%MOD*(i-1)%MOD;
        ans=(ans+divid(a,b)*power(2,abs(i-(n-i))+1)%MOD)%MOD;
    }
    cout << ans << endl;
    return 0;
}
0