結果

問題 No.1310 量子アニーリング
ユーザー 夜
提出日時 2020-12-07 19:12:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,193 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 93,112 KB
実行使用メモリ 8,388 KB
最終ジャッジ日時 2023-10-17 16:37:03
合計ジャッジ時間 2,418 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,388 KB
testcase_01 AC 15 ms
8,388 KB
testcase_02 AC 15 ms
8,388 KB
testcase_03 AC 15 ms
8,388 KB
testcase_04 AC 16 ms
8,388 KB
testcase_05 AC 16 ms
8,388 KB
testcase_06 AC 15 ms
8,388 KB
testcase_07 AC 16 ms
8,388 KB
testcase_08 AC 15 ms
8,388 KB
testcase_09 AC 15 ms
8,388 KB
testcase_10 AC 15 ms
8,388 KB
testcase_11 AC 15 ms
8,388 KB
testcase_12 AC 16 ms
8,388 KB
testcase_13 AC 25 ms
8,388 KB
testcase_14 AC 30 ms
8,388 KB
testcase_15 AC 34 ms
8,388 KB
testcase_16 AC 34 ms
8,388 KB
testcase_17 AC 44 ms
8,388 KB
testcase_18 AC 52 ms
8,388 KB
testcase_19 AC 31 ms
8,388 KB
testcase_20 AC 22 ms
8,388 KB
testcase_21 AC 19 ms
8,388 KB
testcase_22 AC 54 ms
8,388 KB
testcase_23 AC 26 ms
8,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long fac[200020], finv[200020], inv[200020];
long long mod = 998244353;
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200020; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COM(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
	COMinit();
	long long n;
	cin >> n;
	long long now = n;
	long long ans = 0;
	for (long long i = 0; i <= n; i += 2) {
		long long x = 2;
		long long y = abs(now);
		long long ans1 = 1;
		while (y > 0) {
			if ((y & 1) == 1) {
				ans1 = ans1 * x % mod;
			}
			x = x * x % mod;
			y >>= 1;
		}
		ans1 *= COM(n, i);
		ans1 %= mod;
		ans1 *= 2;
		ans %= mod;
		ans += ans1;
		ans %= mod;
		now -= 4;
	}
	cout << ans << endl;
}
0