結果

問題 No.856 増える演算
ユーザー convexineqconvexineq
提出日時 2021-04-03 16:21:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,719 bytes
コンパイル時間 1,127 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 99,292 KB
最終ジャッジ日時 2023-08-26 07:05:34
合計ジャッジ時間 24,602 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 186 ms
81,228 KB
testcase_01 AC 181 ms
81,124 KB
testcase_02 AC 181 ms
80,972 KB
testcase_03 AC 179 ms
81,256 KB
testcase_04 AC 180 ms
81,236 KB
testcase_05 AC 180 ms
81,160 KB
testcase_06 AC 179 ms
81,004 KB
testcase_07 AC 181 ms
80,788 KB
testcase_08 AC 180 ms
80,960 KB
testcase_09 AC 180 ms
80,964 KB
testcase_10 AC 181 ms
81,228 KB
testcase_11 AC 179 ms
81,236 KB
testcase_12 AC 180 ms
81,236 KB
testcase_13 AC 179 ms
81,216 KB
testcase_14 AC 179 ms
80,968 KB
testcase_15 AC 181 ms
81,164 KB
testcase_16 AC 183 ms
81,172 KB
testcase_17 AC 182 ms
80,944 KB
testcase_18 AC 182 ms
80,968 KB
testcase_19 AC 183 ms
81,196 KB
testcase_20 AC 183 ms
80,920 KB
testcase_21 AC 181 ms
81,060 KB
testcase_22 AC 181 ms
80,920 KB
testcase_23 AC 193 ms
81,492 KB
testcase_24 AC 196 ms
81,844 KB
testcase_25 AC 195 ms
81,432 KB
testcase_26 AC 182 ms
80,976 KB
testcase_27 AC 181 ms
81,184 KB
testcase_28 AC 193 ms
81,316 KB
testcase_29 AC 192 ms
81,396 KB
testcase_30 AC 191 ms
81,412 KB
testcase_31 AC 190 ms
81,560 KB
testcase_32 AC 191 ms
81,536 KB
testcase_33 AC 198 ms
81,564 KB
testcase_34 AC 212 ms
83,868 KB
testcase_35 AC 201 ms
82,196 KB
testcase_36 AC 211 ms
83,608 KB
testcase_37 AC 208 ms
83,164 KB
testcase_38 AC 192 ms
81,416 KB
testcase_39 AC 192 ms
81,600 KB
testcase_40 AC 196 ms
81,624 KB
testcase_41 AC 194 ms
81,600 KB
testcase_42 AC 212 ms
84,000 KB
testcase_43 AC 195 ms
81,568 KB
testcase_44 AC 182 ms
81,172 KB
testcase_45 AC 190 ms
81,668 KB
testcase_46 AC 197 ms
81,348 KB
testcase_47 AC 194 ms
81,892 KB
testcase_48 AC 204 ms
82,380 KB
testcase_49 AC 197 ms
81,552 KB
testcase_50 AC 206 ms
82,760 KB
testcase_51 AC 211 ms
83,588 KB
testcase_52 AC 214 ms
83,900 KB
testcase_53 AC 302 ms
88,824 KB
testcase_54 AC 258 ms
83,208 KB
testcase_55 AC 300 ms
87,784 KB
testcase_56 AC 250 ms
82,296 KB
testcase_57 AC 303 ms
88,928 KB
testcase_58 AC 283 ms
85,584 KB
testcase_59 AC 339 ms
93,312 KB
testcase_60 AC 267 ms
84,320 KB
testcase_61 AC 339 ms
94,892 KB
testcase_62 AC 324 ms
91,772 KB
testcase_63 AC 199 ms
81,244 KB
testcase_64 AC 317 ms
90,064 KB
testcase_65 AC 241 ms
81,832 KB
testcase_66 AC 270 ms
84,244 KB
testcase_67 AC 288 ms
86,744 KB
testcase_68 AC 324 ms
91,504 KB
testcase_69 AC 321 ms
91,444 KB
testcase_70 AC 352 ms
94,884 KB
testcase_71 AC 331 ms
92,912 KB
testcase_72 AC 311 ms
89,876 KB
testcase_73 AC 366 ms
97,172 KB
testcase_74 AC 362 ms
97,008 KB
testcase_75 AC 361 ms
96,948 KB
testcase_76 AC 367 ms
96,964 KB
testcase_77 AC 369 ms
97,104 KB
testcase_78 AC 361 ms
97,156 KB
testcase_79 AC 363 ms
96,924 KB
testcase_80 AC 362 ms
96,972 KB
testcase_81 AC 362 ms
97,128 KB
testcase_82 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

ROOT = 3
MOD = 998244353
roots  = [pow(ROOT,(MOD-1)>>i,MOD) for i in range(24)] # 1 の 2^i 乗根
iroots = [pow(x,MOD-2,MOD) for x in roots] # 1 の 2^i 乗根の逆元

def untt(a,n):
    for i in range(n):
        m = 1<<(n-i-1)
        for s in range(1<<i):
            w_N = 1
            s *= m*2
            for p in range(m):
                a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m])%MOD, (a[s+p]-a[s+p+m])*w_N%MOD
                w_N = w_N*roots[n-i]%MOD

def iuntt(a,n):
    for i in range(n):
        m = 1<<i
        for s in range(1<<(n-i-1)):
            w_N = 1
            s *= m*2
            for p in range(m):
                a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m]*w_N)%MOD, (a[s+p]-a[s+p+m]*w_N)%MOD
                w_N = w_N*iroots[i+1]%MOD
            
    inv = pow((MOD+1)//2,n,MOD)
    for i in range(1<<n):
        a[i] = a[i]*inv%MOD

def pow2(a):
    la = len(a)
    deg = 2*la-2
    n = deg.bit_length()
    N = 1<<n
    a += [0]*(N-len(a))
    #b += [0]*(N-len(b))
    untt(a,n)
    #untt(b,n)
    for i in range(N):
      a[i] = a[i]*a[i]%MOD
    iuntt(a,n)
    return a[:deg+1]

n = int(input())
*a, = map(int,input().split())
M = 10**5+1
v = [0]*M
for ai in a: v[ai] += 1
res = pow2(v)
for ai in a: res[2*ai] -= 1


MOD2 = 10**9+7
ans = 1
for i,ri in enumerate(res):
    ans *= pow(i,ri//2,MOD2)
    ans %= MOD2
v = 0
for ai in a[::-1]:
    ans *= pow(ai,v,MOD2)
    ans %= MOD2
    v += ai

L = R = -1
v = 1e18
rmin = n-1
from math import log
for i in range(n-1)[::-1]:
    w = a[rmin]*log(a[i]) + log(a[i] + a[rmin])
    if w < v:
        L = i
        R = rmin
        v = w
    if a[i] < a[rmin]:
        rmin = i

v = (a[L]+a[R])*pow(a[L],a[R],MOD2)%MOD2
print(ans*pow(v,MOD2-2,MOD2)%MOD2)
0