結果

問題 No.1310 量子アニーリング
ユーザー shotoyooshotoyoo
提出日時 2020-12-08 00:34:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,140 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 108,956 KB
最終ジャッジ日時 2023-10-17 16:48:05
合計ジャッジ時間 3,217 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,556 KB
testcase_01 AC 37 ms
53,556 KB
testcase_02 AC 35 ms
53,556 KB
testcase_03 AC 36 ms
53,556 KB
testcase_04 AC 35 ms
53,556 KB
testcase_05 AC 35 ms
53,556 KB
testcase_06 AC 36 ms
53,556 KB
testcase_07 AC 36 ms
53,556 KB
testcase_08 AC 36 ms
53,556 KB
testcase_09 AC 37 ms
53,556 KB
testcase_10 AC 43 ms
60,044 KB
testcase_11 AC 43 ms
60,044 KB
testcase_12 AC 50 ms
64,400 KB
testcase_13 AC 63 ms
76,120 KB
testcase_14 AC 69 ms
80,744 KB
testcase_15 AC 75 ms
86,824 KB
testcase_16 AC 76 ms
87,128 KB
testcase_17 AC 87 ms
95,612 KB
testcase_18 AC 101 ms
108,956 KB
testcase_19 AC 73 ms
82,668 KB
testcase_20 AC 59 ms
72,916 KB
testcase_21 AC 55 ms
67,544 KB
testcase_22 AC 99 ms
108,876 KB
testcase_23 AC 64 ms
76,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
### 素数の逆元とCombination

# M = 10**9+7 # 出力の制限
M = 998244353
N = 2*n+10 # 必要なテーブルサイズ
g1 = [0] * (N+1) # 元テーブル
g2 = [0] * (N+1) #逆元テーブル
inverse = [0] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 
for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 
def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return ((g1[n] * g2[r] % M) * g2[n-r]) % M
def perm(n, r, M):
    if (r<0 or r>n):
        return 0
    return (g1[n] * g2[n-r]) % M
vs = [1]
v = 1
for i in range(2*n+10):
    v *= 2
    v %= M
    vs.append(v)
def sub(n):
    ans = 2 * vs[n]
    for i in range(2,n+1,2):
        ans += 2 * cmb(n,i,M) * vs[abs(-n+2*i)]
    return ans
ans = sub(n)
print(ans%M)
0