結果

問題 No.856 増える演算
ユーザー convexineqconvexineq
提出日時 2021-04-03 16:42:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 544 ms / 3,153 ms
コード長 1,538 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 182,548 KB
最終ジャッジ日時 2023-08-26 07:53:24
合計ジャッジ時間 38,636 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 343 ms
175,048 KB
testcase_01 AC 348 ms
175,072 KB
testcase_02 AC 347 ms
175,232 KB
testcase_03 AC 345 ms
175,060 KB
testcase_04 AC 351 ms
174,980 KB
testcase_05 AC 343 ms
174,996 KB
testcase_06 AC 345 ms
175,196 KB
testcase_07 AC 359 ms
175,116 KB
testcase_08 AC 350 ms
175,156 KB
testcase_09 AC 346 ms
175,292 KB
testcase_10 AC 344 ms
174,956 KB
testcase_11 AC 342 ms
175,372 KB
testcase_12 AC 345 ms
174,932 KB
testcase_13 AC 342 ms
175,052 KB
testcase_14 AC 352 ms
175,140 KB
testcase_15 AC 354 ms
175,000 KB
testcase_16 AC 354 ms
175,324 KB
testcase_17 AC 347 ms
175,068 KB
testcase_18 AC 344 ms
175,324 KB
testcase_19 AC 342 ms
175,048 KB
testcase_20 AC 343 ms
175,300 KB
testcase_21 AC 338 ms
175,200 KB
testcase_22 AC 345 ms
175,232 KB
testcase_23 AC 357 ms
175,276 KB
testcase_24 AC 355 ms
175,200 KB
testcase_25 AC 355 ms
175,292 KB
testcase_26 AC 343 ms
175,052 KB
testcase_27 AC 355 ms
175,324 KB
testcase_28 AC 359 ms
175,084 KB
testcase_29 AC 360 ms
175,228 KB
testcase_30 AC 370 ms
175,276 KB
testcase_31 AC 352 ms
175,228 KB
testcase_32 AC 355 ms
175,040 KB
testcase_33 AC 358 ms
175,188 KB
testcase_34 AC 366 ms
175,592 KB
testcase_35 AC 370 ms
175,820 KB
testcase_36 AC 377 ms
175,960 KB
testcase_37 AC 380 ms
175,812 KB
testcase_38 AC 357 ms
175,120 KB
testcase_39 AC 360 ms
175,240 KB
testcase_40 AC 363 ms
175,048 KB
testcase_41 AC 358 ms
175,132 KB
testcase_42 AC 381 ms
175,900 KB
testcase_43 AC 360 ms
175,100 KB
testcase_44 AC 361 ms
174,944 KB
testcase_45 AC 377 ms
175,168 KB
testcase_46 AC 371 ms
175,136 KB
testcase_47 AC 369 ms
175,024 KB
testcase_48 AC 376 ms
175,640 KB
testcase_49 AC 357 ms
175,288 KB
testcase_50 AC 360 ms
175,776 KB
testcase_51 AC 368 ms
176,124 KB
testcase_52 AC 378 ms
175,876 KB
testcase_53 AC 460 ms
182,548 KB
testcase_54 AC 417 ms
175,856 KB
testcase_55 AC 464 ms
182,000 KB
testcase_56 AC 395 ms
175,460 KB
testcase_57 AC 469 ms
182,372 KB
testcase_58 AC 451 ms
182,208 KB
testcase_59 AC 524 ms
181,452 KB
testcase_60 AC 432 ms
175,552 KB
testcase_61 AC 515 ms
181,380 KB
testcase_62 AC 501 ms
182,204 KB
testcase_63 AC 361 ms
175,208 KB
testcase_64 AC 480 ms
181,940 KB
testcase_65 AC 400 ms
175,484 KB
testcase_66 AC 432 ms
175,604 KB
testcase_67 AC 457 ms
182,116 KB
testcase_68 AC 485 ms
182,180 KB
testcase_69 AC 491 ms
182,544 KB
testcase_70 AC 507 ms
180,196 KB
testcase_71 AC 482 ms
182,108 KB
testcase_72 AC 482 ms
182,220 KB
testcase_73 AC 529 ms
179,644 KB
testcase_74 AC 527 ms
179,500 KB
testcase_75 AC 522 ms
179,600 KB
testcase_76 AC 528 ms
179,680 KB
testcase_77 AC 526 ms
179,912 KB
testcase_78 AC 533 ms
179,516 KB
testcase_79 AC 527 ms
179,872 KB
testcase_80 AC 544 ms
179,648 KB
testcase_81 AC 518 ms
179,568 KB
testcase_82 AC 449 ms
179,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import pi,cos,sin,log

ROOT = 3
roots  = [cos(2*pi/2**i) + sin(2*pi/2**i)*1j for i in range(24)]
iroots  = [cos(2*pi/2**i) - sin(2*pi/2**i)*1j for i in range(24)]

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]), (a[s+p]-a[s+p+m])*w_N
                w_N = w_N*roots[n-i]

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)/2, (a[s+p]-a[s+p+m]*w_N)/2
                w_N = w_N*iroots[i+1]
            
def pow2(a):
    la = len(a)
    deg = 2*la-2
    n = deg.bit_length()
    N = 1<<n
    a += [0.0]*(N-la)
    untt(a,n)
    for i in range(N):
      a[i] *= a[i]
    iuntt(a,n)
    return a[:deg+1]

n = int(input())
*a, = map(int,input().split())
M = 10**5+1
v = [0.0j]*M
for ai in a: v[ai] += 1.0
res = pow2(v)
for ai in a: res[2*ai] -= 1.0
MOD2 = 10**9+7
ans = 1
for i,ri in enumerate(res):
    ans = ans*pow(i,int(round(ri.real))//2,MOD2)%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
for i in range(n-1)[::-1]:
    w = a[rmin]*log(a[i]) + log(a[i] + a[rmin])
    if w < v:
        L,R,v = i,rmin,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