結果
問題 | No.856 増える演算 |
ユーザー | maspy |
提出日時 | 2020-04-10 02:38:12 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 1,127 ms / 3,153 ms |
コード長 | 1,472 bytes |
コンパイル時間 | 517 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 60,004 KB |
最終ジャッジ日時 | 2024-09-14 05:57:07 |
合計ジャッジ時間 | 84,129 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 869 ms
56,764 KB |
testcase_01 | AC | 866 ms
57,424 KB |
testcase_02 | AC | 862 ms
58,380 KB |
testcase_03 | AC | 866 ms
58,216 KB |
testcase_04 | AC | 863 ms
56,812 KB |
testcase_05 | AC | 866 ms
58,192 KB |
testcase_06 | AC | 874 ms
58,164 KB |
testcase_07 | AC | 866 ms
58,096 KB |
testcase_08 | AC | 869 ms
56,976 KB |
testcase_09 | AC | 877 ms
57,476 KB |
testcase_10 | AC | 869 ms
58,664 KB |
testcase_11 | AC | 872 ms
56,576 KB |
testcase_12 | AC | 872 ms
57,428 KB |
testcase_13 | AC | 872 ms
56,256 KB |
testcase_14 | AC | 881 ms
58,248 KB |
testcase_15 | AC | 877 ms
56,700 KB |
testcase_16 | AC | 880 ms
59,216 KB |
testcase_17 | AC | 875 ms
55,992 KB |
testcase_18 | AC | 878 ms
58,832 KB |
testcase_19 | AC | 877 ms
59,664 KB |
testcase_20 | AC | 879 ms
58,100 KB |
testcase_21 | AC | 878 ms
58,376 KB |
testcase_22 | AC | 871 ms
59,220 KB |
testcase_23 | AC | 878 ms
57,072 KB |
testcase_24 | AC | 887 ms
58,176 KB |
testcase_25 | AC | 879 ms
58,496 KB |
testcase_26 | AC | 877 ms
58,428 KB |
testcase_27 | AC | 870 ms
57,060 KB |
testcase_28 | AC | 871 ms
56,448 KB |
testcase_29 | AC | 877 ms
58,660 KB |
testcase_30 | AC | 897 ms
58,236 KB |
testcase_31 | AC | 877 ms
56,420 KB |
testcase_32 | AC | 879 ms
56,740 KB |
testcase_33 | AC | 900 ms
56,972 KB |
testcase_34 | AC | 928 ms
57,320 KB |
testcase_35 | AC | 905 ms
55,876 KB |
testcase_36 | AC | 922 ms
56,372 KB |
testcase_37 | AC | 916 ms
56,168 KB |
testcase_38 | AC | 877 ms
57,076 KB |
testcase_39 | AC | 878 ms
56,896 KB |
testcase_40 | AC | 898 ms
57,944 KB |
testcase_41 | AC | 895 ms
57,764 KB |
testcase_42 | AC | 931 ms
58,428 KB |
testcase_43 | AC | 898 ms
57,228 KB |
testcase_44 | AC | 889 ms
55,740 KB |
testcase_45 | AC | 878 ms
59,588 KB |
testcase_46 | AC | 895 ms
58,076 KB |
testcase_47 | AC | 892 ms
56,740 KB |
testcase_48 | AC | 912 ms
58,244 KB |
testcase_49 | AC | 901 ms
57,984 KB |
testcase_50 | AC | 905 ms
59,792 KB |
testcase_51 | AC | 912 ms
59,692 KB |
testcase_52 | AC | 930 ms
57,620 KB |
testcase_53 | AC | 1,030 ms
58,540 KB |
testcase_54 | AC | 960 ms
55,920 KB |
testcase_55 | AC | 1,019 ms
57,536 KB |
testcase_56 | AC | 943 ms
57,856 KB |
testcase_57 | AC | 1,028 ms
55,896 KB |
testcase_58 | AC | 991 ms
59,508 KB |
testcase_59 | AC | 1,076 ms
59,092 KB |
testcase_60 | AC | 960 ms
57,784 KB |
testcase_61 | AC | 1,069 ms
58,612 KB |
testcase_62 | AC | 1,058 ms
58,768 KB |
testcase_63 | AC | 885 ms
57,276 KB |
testcase_64 | AC | 1,043 ms
57,332 KB |
testcase_65 | AC | 940 ms
56,704 KB |
testcase_66 | AC | 974 ms
57,184 KB |
testcase_67 | AC | 1,007 ms
56,612 KB |
testcase_68 | AC | 1,052 ms
58,076 KB |
testcase_69 | AC | 1,049 ms
59,024 KB |
testcase_70 | AC | 1,104 ms
56,864 KB |
testcase_71 | AC | 1,059 ms
59,996 KB |
testcase_72 | AC | 1,044 ms
58,420 KB |
testcase_73 | AC | 1,126 ms
59,468 KB |
testcase_74 | AC | 1,121 ms
57,952 KB |
testcase_75 | AC | 1,125 ms
58,232 KB |
testcase_76 | AC | 1,107 ms
60,004 KB |
testcase_77 | AC | 1,110 ms
57,104 KB |
testcase_78 | AC | 1,118 ms
59,124 KB |
testcase_79 | AC | 1,122 ms
57,076 KB |
testcase_80 | AC | 1,125 ms
58,024 KB |
testcase_81 | AC | 1,127 ms
56,792 KB |
testcase_82 | AC | 1,030 ms
55,908 KB |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np MOD = 10 ** 9 + 7 def cumprod(A, MOD=MOD): L = len(A) Lsq = int(L**.5 + 1) A = np.resize(A, Lsq**2).reshape(Lsq, Lsq) for n in range(1, Lsq): A[:, n] *= A[:, n - 1] A[:, n] %= MOD for n in range(1, Lsq): A[n] *= A[n - 1, -1] A[n] %= MOD return A.ravel()[:L] def power(A, n): prod = np.ones_like(A, np.int64) powA = A.copy() for i in range(40): prod[n & 1 == 1] *= powA[n & 1 == 1] n >>= 1 powA **= 2 powA %= MOD prod %= MOD return prod def prod_1(A): fft = np.fft.rfft ifft = np.fft.irfft fft_len = 1 << 18 f = np.bincount(A) Ff = fft(f, fft_len) f = np.rint(ifft(Ff ** 2, fft_len)).astype(np.int64) np.add.at(f, A * 2, -1) f >>= 1 x = np.arange(len(f)) x = power(x, f) return cumprod(x)[-1] def prod_2(A): B = cumprod(A) x = power(B[:-1], A[1:].copy()) return cumprod(x)[-1] def find_min(A): B = np.minimum.accumulate(A)[:-1] C = A[1:] nums = np.log(B + C) + np.log(B) * C i = np.argmin(nums) b, c = int(B[i]), int(C[i]) return (b + c) * pow(b, c, MOD) % MOD N = int(readline()) A = np.array(read().split(), np.int64) a, b, c = map(int, (prod_1(A), prod_2(A), find_min(A))) answer = a * b * pow(c, MOD - 2, MOD) % MOD print(answer)