結果

問題 No.1310 量子アニーリング
ユーザー hirokazu1020hirokazu1020
提出日時 2020-12-08 02:22:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,476 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 97,564 KB
実行使用メモリ 8,360 KB
最終ジャッジ日時 2023-10-17 16:53:08
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
8,360 KB
testcase_01 AC 5 ms
8,360 KB
testcase_02 AC 5 ms
8,360 KB
testcase_03 AC 5 ms
8,360 KB
testcase_04 AC 6 ms
8,360 KB
testcase_05 AC 5 ms
8,360 KB
testcase_06 AC 5 ms
8,360 KB
testcase_07 AC 5 ms
8,360 KB
testcase_08 AC 5 ms
8,360 KB
testcase_09 AC 5 ms
8,360 KB
testcase_10 AC 5 ms
8,360 KB
testcase_11 AC 6 ms
8,360 KB
testcase_12 AC 6 ms
8,360 KB
testcase_13 AC 7 ms
8,360 KB
testcase_14 AC 9 ms
8,360 KB
testcase_15 AC 9 ms
8,360 KB
testcase_16 AC 10 ms
8,360 KB
testcase_17 AC 12 ms
8,360 KB
testcase_18 AC 14 ms
8,360 KB
testcase_19 AC 9 ms
8,360 KB
testcase_20 AC 7 ms
8,360 KB
testcase_21 AC 6 ms
8,360 KB
testcase_22 AC 14 ms
8,360 KB
testcase_23 AC 8 ms
8,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

#define MOD 998244353


long long pow_mod(long long x, long long y) {
	int res = 1;
	while (y) {
		if (y & 1)res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}



#define MAXN 200000
long long inv[MAXN + 1];
long long fact[MAXN + 1];
long long ifact[MAXN + 1];
void init() {
	inv[1] = 1;
	for (int i = 2; i <= MAXN; i++) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= MAXN; i++) {
		fact[i] = i * fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	init();
	
	int n;
	cin >> n;

	long long ans = 0;
	for (int i = 0; i <= n; i += 2) {
		ans += 2 * C(n, i) * pow_mod(2, abs(n - 2 * i));
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}
0