結果
問題 | No.856 増える演算 |
ユーザー | convexineq |
提出日時 | 2021-04-03 16:42:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 563 ms / 3,153 ms |
コード長 | 1,538 bytes |
コンパイル時間 | 487 ms |
コンパイル使用メモリ | 81,816 KB |
実行使用メモリ | 181,572 KB |
最終ジャッジ日時 | 2024-06-07 03:05:00 |
合計ジャッジ時間 | 36,428 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 341 ms
174,276 KB |
testcase_01 | AC | 347 ms
174,028 KB |
testcase_02 | AC | 338 ms
174,172 KB |
testcase_03 | AC | 337 ms
173,896 KB |
testcase_04 | AC | 339 ms
173,916 KB |
testcase_05 | AC | 343 ms
173,772 KB |
testcase_06 | AC | 352 ms
173,920 KB |
testcase_07 | AC | 348 ms
174,224 KB |
testcase_08 | AC | 349 ms
173,908 KB |
testcase_09 | AC | 345 ms
173,768 KB |
testcase_10 | AC | 346 ms
173,908 KB |
testcase_11 | AC | 346 ms
174,032 KB |
testcase_12 | AC | 343 ms
173,796 KB |
testcase_13 | AC | 349 ms
173,920 KB |
testcase_14 | AC | 340 ms
173,764 KB |
testcase_15 | AC | 340 ms
173,924 KB |
testcase_16 | AC | 344 ms
173,916 KB |
testcase_17 | AC | 344 ms
173,764 KB |
testcase_18 | AC | 345 ms
173,516 KB |
testcase_19 | AC | 341 ms
173,928 KB |
testcase_20 | AC | 343 ms
174,052 KB |
testcase_21 | AC | 342 ms
174,044 KB |
testcase_22 | AC | 344 ms
173,920 KB |
testcase_23 | AC | 359 ms
174,012 KB |
testcase_24 | AC | 355 ms
173,916 KB |
testcase_25 | AC | 357 ms
173,816 KB |
testcase_26 | AC | 349 ms
173,772 KB |
testcase_27 | AC | 348 ms
173,780 KB |
testcase_28 | AC | 357 ms
174,400 KB |
testcase_29 | AC | 358 ms
174,132 KB |
testcase_30 | AC | 359 ms
174,120 KB |
testcase_31 | AC | 353 ms
174,484 KB |
testcase_32 | AC | 356 ms
174,156 KB |
testcase_33 | AC | 364 ms
174,072 KB |
testcase_34 | AC | 375 ms
174,596 KB |
testcase_35 | AC | 369 ms
174,664 KB |
testcase_36 | AC | 377 ms
174,544 KB |
testcase_37 | AC | 377 ms
174,664 KB |
testcase_38 | AC | 357 ms
174,212 KB |
testcase_39 | AC | 359 ms
174,100 KB |
testcase_40 | AC | 360 ms
174,008 KB |
testcase_41 | AC | 364 ms
174,404 KB |
testcase_42 | AC | 379 ms
174,152 KB |
testcase_43 | AC | 362 ms
174,328 KB |
testcase_44 | AC | 345 ms
173,920 KB |
testcase_45 | AC | 359 ms
174,244 KB |
testcase_46 | AC | 364 ms
174,404 KB |
testcase_47 | AC | 358 ms
173,904 KB |
testcase_48 | AC | 370 ms
174,004 KB |
testcase_49 | AC | 363 ms
174,216 KB |
testcase_50 | AC | 372 ms
174,688 KB |
testcase_51 | AC | 378 ms
174,840 KB |
testcase_52 | AC | 382 ms
174,348 KB |
testcase_53 | AC | 476 ms
174,944 KB |
testcase_54 | AC | 431 ms
174,540 KB |
testcase_55 | AC | 468 ms
175,028 KB |
testcase_56 | AC | 425 ms
174,500 KB |
testcase_57 | AC | 483 ms
174,764 KB |
testcase_58 | AC | 456 ms
174,648 KB |
testcase_59 | AC | 527 ms
181,528 KB |
testcase_60 | AC | 441 ms
174,224 KB |
testcase_61 | AC | 532 ms
181,424 KB |
testcase_62 | AC | 515 ms
181,572 KB |
testcase_63 | AC | 371 ms
174,104 KB |
testcase_64 | AC | 504 ms
181,356 KB |
testcase_65 | AC | 415 ms
174,044 KB |
testcase_66 | AC | 441 ms
174,660 KB |
testcase_67 | AC | 461 ms
174,636 KB |
testcase_68 | AC | 509 ms
181,500 KB |
testcase_69 | AC | 511 ms
181,348 KB |
testcase_70 | AC | 532 ms
180,872 KB |
testcase_71 | AC | 517 ms
181,436 KB |
testcase_72 | AC | 498 ms
174,084 KB |
testcase_73 | AC | 563 ms
180,620 KB |
testcase_74 | AC | 553 ms
180,616 KB |
testcase_75 | AC | 546 ms
180,596 KB |
testcase_76 | AC | 545 ms
180,616 KB |
testcase_77 | AC | 543 ms
180,368 KB |
testcase_78 | AC | 537 ms
180,876 KB |
testcase_79 | AC | 541 ms
180,596 KB |
testcase_80 | AC | 538 ms
180,848 KB |
testcase_81 | AC | 540 ms
180,596 KB |
testcase_82 | AC | 469 ms
180,328 KB |
ソースコード
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)