結果
問題 | No.1753 Don't cheat. |
ユーザー | chineristAC |
提出日時 | 2021-11-19 22:03:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,230 ms / 3,000 ms |
コード長 | 2,406 bytes |
コンパイル時間 | 240 ms |
コンパイル使用メモリ | 82,656 KB |
実行使用メモリ | 85,316 KB |
最終ジャッジ日時 | 2024-06-10 09:03:13 |
合計ジャッジ時間 | 72,135 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,156 ms
84,288 KB |
testcase_01 | AC | 2,120 ms
84,024 KB |
testcase_02 | AC | 2,101 ms
84,280 KB |
testcase_03 | AC | 2,142 ms
84,036 KB |
testcase_04 | AC | 2,092 ms
84,168 KB |
testcase_05 | AC | 2,111 ms
84,028 KB |
testcase_06 | AC | 2,124 ms
84,156 KB |
testcase_07 | AC | 2,122 ms
84,252 KB |
testcase_08 | AC | 2,105 ms
84,224 KB |
testcase_09 | AC | 2,186 ms
84,104 KB |
testcase_10 | AC | 2,131 ms
84,172 KB |
testcase_11 | AC | 2,115 ms
84,260 KB |
testcase_12 | AC | 2,156 ms
84,232 KB |
testcase_13 | AC | 2,170 ms
84,244 KB |
testcase_14 | AC | 2,160 ms
84,096 KB |
testcase_15 | AC | 2,143 ms
84,348 KB |
testcase_16 | AC | 2,143 ms
84,100 KB |
testcase_17 | AC | 2,222 ms
84,508 KB |
testcase_18 | AC | 2,150 ms
84,368 KB |
testcase_19 | AC | 2,164 ms
84,916 KB |
testcase_20 | AC | 2,134 ms
84,488 KB |
testcase_21 | AC | 2,185 ms
85,316 KB |
testcase_22 | AC | 2,134 ms
85,232 KB |
testcase_23 | AC | 2,126 ms
84,256 KB |
testcase_24 | AC | 2,133 ms
84,468 KB |
testcase_25 | AC | 2,148 ms
84,240 KB |
testcase_26 | AC | 2,185 ms
84,588 KB |
testcase_27 | AC | 2,184 ms
84,224 KB |
testcase_28 | AC | 2,180 ms
83,964 KB |
testcase_29 | AC | 2,221 ms
84,096 KB |
testcase_30 | AC | 2,193 ms
84,220 KB |
testcase_31 | AC | 2,230 ms
84,328 KB |
ソースコード
N = 2*10**5 mod = 998244353 g1 = [1]*(N+1) # 元テーブル g2 = [1]*(N+1) #逆元テーブル inverse = [1]*(N+1) #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1[i]=( ( g1[i-1] * i ) % mod ) inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod ) g2[i]=( (g2[i-1] * inverse[i]) % mod ) inverse[0]=0 def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod def fwt(n,A): assert len(A) == 2**n for i in range(n): t = 2**i for j in range(2**n): if j&t==0: A[j] += A[j|t] return A def ifwt(n,A): assert len(A) == 2**n for i in range(n): t = 2**i for j in range(2**n): if j&t==0: A[j] -= A[j|t] return A inv = pow(1024,mod-2,mod) def _fourier(f, inverse = False): f = f[:] n = (len(f) - 1).bit_length() for d in range(n): for U in range(1 << n): if not U >> d & 1: s, t = f[U], f[U | 1 << d] f[U], f[U | 1 << d] = (s + t)%mod, (s - t)%mod if inverse: f = [v *inv % mod for v in f] return f def convolution(f, g): return _fourier([a * b % mod for a, b in zip(_fourier(f), _fourier(g))], inverse = 1) import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) A = li() S = sum(A) P = [A[i]*pow(S,mod-2,mod)%mod for i in range(N+1)] + [0] * (1023-N) res = P[0] for i in range(1,1024): f = [0] + [P[j] for j in range(1,1024)] g = [f[j] for j in range(1024)] g[i] = 0 af = _fourier(f) ag = _fourier(g) for j in range(1024): af[j] = af[j] * pow(1-af[j],mod-2,mod) % mod ag[j] = ag[j] * pow(1-ag[j],mod-2,mod) % mod tmp = _fourier([af[i]-ag[i] for i in range(1024)],True) #print(f,g) #print([f[i]*30 % mod for i in range(4)]) res += P[0] * tmp[i] % mod res %= mod f = [0] + [P[j] for j in range(1,1024)] af = _fourier(f) for j in range(1024): af[j] = af[j] * pow(1-af[j],mod-2,mod) % mod ag[j] = ag[j] * pow(1-ag[j],mod-2,mod) % mod f = _fourier(af,True) res += P[0] * f[0] % mod res %= mod print((1-res)%mod)