結果

問題 No.1310 量子アニーリング
ユーザー anagohirameanagohirame
提出日時 2020-12-24 00:05:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 80,360 KB
最終ジャッジ日時 2023-10-21 15:22:18
合計ジャッジ時間 3,143 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
62,556 KB
testcase_01 AC 49 ms
62,556 KB
testcase_02 AC 49 ms
62,556 KB
testcase_03 AC 50 ms
62,556 KB
testcase_04 AC 49 ms
62,556 KB
testcase_05 AC 49 ms
62,556 KB
testcase_06 AC 55 ms
62,556 KB
testcase_07 AC 50 ms
62,556 KB
testcase_08 AC 50 ms
62,556 KB
testcase_09 AC 51 ms
62,556 KB
testcase_10 AC 51 ms
62,556 KB
testcase_11 AC 54 ms
62,716 KB
testcase_12 AC 63 ms
67,256 KB
testcase_13 AC 78 ms
71,872 KB
testcase_14 AC 85 ms
75,024 KB
testcase_15 AC 92 ms
75,960 KB
testcase_16 AC 95 ms
76,176 KB
testcase_17 AC 108 ms
80,360 KB
testcase_18 AC 115 ms
77,528 KB
testcase_19 AC 89 ms
75,480 KB
testcase_20 AC 72 ms
71,104 KB
testcase_21 AC 67 ms
68,292 KB
testcase_22 AC 114 ms
77,460 KB
testcase_23 AC 77 ms
71,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
list_size = 200001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % MOD

def comb(n, r):
	if n < r or r < 0:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (f_list[n] * f_r_list[n-r] * f_r_list[r]) % MOD 

n = int(input())
ans = 0
two = [1 for _ in range(n+1)]
for i in range(1, n+1):
	two[i] = (two[i-1] * 2) % MOD
inv = pow(n, MOD-2, MOD)
for i in range(0, n+1, 2):
	ans += pow(2, abs(n - 2*i) + 1, MOD) * comb(n, i)
	ans %= MOD
print(ans)
0