結果

問題 No.856 増える演算
ユーザー convexineqconvexineq
提出日時 2021-04-03 16:17:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,733 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 98,608 KB
最終ジャッジ日時 2023-08-26 07:01:05
合計ジャッジ時間 25,645 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
80,648 KB
testcase_01 AC 183 ms
81,184 KB
testcase_02 AC 182 ms
80,924 KB
testcase_03 AC 181 ms
80,632 KB
testcase_04 AC 181 ms
80,932 KB
testcase_05 AC 180 ms
80,936 KB
testcase_06 AC 181 ms
81,212 KB
testcase_07 AC 181 ms
80,932 KB
testcase_08 AC 180 ms
80,956 KB
testcase_09 AC 181 ms
80,940 KB
testcase_10 AC 180 ms
80,936 KB
testcase_11 AC 180 ms
80,680 KB
testcase_12 AC 181 ms
81,212 KB
testcase_13 AC 181 ms
81,184 KB
testcase_14 AC 180 ms
80,896 KB
testcase_15 AC 181 ms
80,816 KB
testcase_16 AC 180 ms
81,220 KB
testcase_17 AC 181 ms
81,232 KB
testcase_18 AC 180 ms
80,852 KB
testcase_19 AC 180 ms
81,060 KB
testcase_20 AC 180 ms
80,996 KB
testcase_21 AC 179 ms
80,980 KB
testcase_22 AC 181 ms
80,632 KB
testcase_23 AC 195 ms
81,300 KB
testcase_24 AC 195 ms
81,612 KB
testcase_25 AC 189 ms
81,472 KB
testcase_26 AC 181 ms
80,940 KB
testcase_27 AC 179 ms
80,856 KB
testcase_28 AC 191 ms
81,424 KB
testcase_29 AC 191 ms
81,420 KB
testcase_30 AC 191 ms
81,712 KB
testcase_31 AC 189 ms
81,580 KB
testcase_32 AC 191 ms
81,456 KB
testcase_33 AC 199 ms
81,656 KB
testcase_34 AC 211 ms
83,956 KB
testcase_35 AC 201 ms
82,132 KB
testcase_36 AC 212 ms
83,636 KB
testcase_37 AC 211 ms
83,044 KB
testcase_38 AC 194 ms
81,420 KB
testcase_39 AC 195 ms
81,580 KB
testcase_40 AC 198 ms
81,580 KB
testcase_41 AC 199 ms
81,544 KB
testcase_42 AC 216 ms
83,828 KB
testcase_43 AC 199 ms
81,416 KB
testcase_44 AC 182 ms
80,944 KB
testcase_45 AC 193 ms
81,564 KB
testcase_46 AC 197 ms
81,460 KB
testcase_47 AC 193 ms
81,512 KB
testcase_48 AC 205 ms
82,332 KB
testcase_49 AC 199 ms
81,492 KB
testcase_50 AC 206 ms
82,616 KB
testcase_51 AC 212 ms
83,684 KB
testcase_52 AC 214 ms
84,012 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 247 ms
82,356 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 202 ms
81,280 KB
testcase_64 WA -
testcase_65 AC 242 ms
81,732 KB
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
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
    v %= MOD2

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