結果

問題 No.856 増える演算
ユーザー convexineqconvexineq
提出日時 2021-04-03 17:03:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 588 ms / 3,153 ms
コード長 1,425 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 182,732 KB
最終ジャッジ日時 2023-08-26 08:44:21
合計ジャッジ時間 41,619 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 380 ms
174,704 KB
testcase_01 AC 382 ms
174,788 KB
testcase_02 AC 379 ms
174,784 KB
testcase_03 AC 378 ms
174,664 KB
testcase_04 AC 375 ms
174,960 KB
testcase_05 AC 386 ms
174,720 KB
testcase_06 AC 379 ms
174,848 KB
testcase_07 AC 378 ms
174,600 KB
testcase_08 AC 377 ms
174,604 KB
testcase_09 AC 377 ms
174,664 KB
testcase_10 AC 379 ms
174,704 KB
testcase_11 AC 380 ms
174,792 KB
testcase_12 AC 378 ms
174,964 KB
testcase_13 AC 381 ms
174,824 KB
testcase_14 AC 384 ms
174,972 KB
testcase_15 AC 381 ms
174,808 KB
testcase_16 AC 378 ms
174,712 KB
testcase_17 AC 382 ms
174,760 KB
testcase_18 AC 378 ms
174,932 KB
testcase_19 AC 376 ms
174,884 KB
testcase_20 AC 381 ms
174,708 KB
testcase_21 AC 383 ms
174,708 KB
testcase_22 AC 378 ms
174,712 KB
testcase_23 AC 393 ms
174,992 KB
testcase_24 AC 389 ms
175,080 KB
testcase_25 AC 389 ms
175,244 KB
testcase_26 AC 380 ms
174,968 KB
testcase_27 AC 382 ms
174,796 KB
testcase_28 AC 390 ms
175,080 KB
testcase_29 AC 391 ms
174,776 KB
testcase_30 AC 390 ms
174,996 KB
testcase_31 AC 391 ms
175,064 KB
testcase_32 AC 393 ms
174,816 KB
testcase_33 AC 399 ms
174,720 KB
testcase_34 AC 413 ms
175,496 KB
testcase_35 AC 405 ms
175,320 KB
testcase_36 AC 417 ms
175,492 KB
testcase_37 AC 410 ms
175,424 KB
testcase_38 AC 396 ms
175,060 KB
testcase_39 AC 394 ms
174,752 KB
testcase_40 AC 401 ms
174,692 KB
testcase_41 AC 402 ms
174,964 KB
testcase_42 AC 420 ms
175,672 KB
testcase_43 AC 398 ms
175,028 KB
testcase_44 AC 385 ms
174,832 KB
testcase_45 AC 394 ms
174,808 KB
testcase_46 AC 401 ms
175,068 KB
testcase_47 AC 404 ms
175,072 KB
testcase_48 AC 405 ms
175,440 KB
testcase_49 AC 403 ms
174,876 KB
testcase_50 AC 412 ms
175,416 KB
testcase_51 AC 417 ms
175,464 KB
testcase_52 AC 423 ms
175,732 KB
testcase_53 AC 522 ms
182,296 KB
testcase_54 AC 462 ms
175,852 KB
testcase_55 AC 520 ms
182,232 KB
testcase_56 AC 447 ms
175,392 KB
testcase_57 AC 526 ms
182,404 KB
testcase_58 AC 500 ms
182,428 KB
testcase_59 AC 557 ms
181,948 KB
testcase_60 AC 472 ms
175,900 KB
testcase_61 AC 565 ms
181,500 KB
testcase_62 AC 548 ms
182,732 KB
testcase_63 AC 404 ms
175,228 KB
testcase_64 AC 537 ms
182,380 KB
testcase_65 AC 450 ms
175,148 KB
testcase_66 AC 472 ms
175,548 KB
testcase_67 AC 515 ms
182,160 KB
testcase_68 AC 544 ms
182,472 KB
testcase_69 AC 541 ms
182,636 KB
testcase_70 AC 570 ms
180,592 KB
testcase_71 AC 549 ms
182,256 KB
testcase_72 AC 539 ms
182,616 KB
testcase_73 AC 586 ms
180,048 KB
testcase_74 AC 581 ms
180,324 KB
testcase_75 AC 586 ms
180,124 KB
testcase_76 AC 588 ms
180,072 KB
testcase_77 AC 581 ms
180,156 KB
testcase_78 AC 582 ms
180,124 KB
testcase_79 AC 583 ms
180,196 KB
testcase_80 AC 586 ms
180,152 KB
testcase_81 AC 580 ms
180,132 KB
testcase_82 AC 494 ms
178,852 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 *= 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 *= iroots[i+1]
            
def pow2(a):
    deg = 2*len(a)-2
    n = deg.bit_length()
    N = 1<<n
    a += [0.0]*(N-len(a))
    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())
V = [0.0j]*(10**5+1)
for ai in a: V[ai] += 1
V = pow2(V)
for ai in a: V[2*ai] -= 1
MOD = 10**9+7
ans = 1
for i,vi in enumerate(V):
    ans = ans*pow(i,int(round(vi.real))//2,MOD)%MOD
v = 0
for ai in a[::-1]:
    ans = ans*pow(ai,v,MOD)%MOD
    v += ai

L,R,r,v = 0,a[n-1],a[n-1],1e9
for ai in a[n-2::-1]:
    w = r*log(ai) + log(ai+r)
    if w < v:
        L,R,v = ai,r,w
    r = min(r,ai)
v = (L+R)*pow(L,R,MOD)%MOD
print(ans*pow(v,MOD-2,MOD)%MOD)
0