Submission #9613690


Source Code Expand

Copy
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = np.array(read().split(),np.int64)

MOD = 10 ** 9 + 7

U = 10 ** 6 + 10
is_prime = np.zeros(U, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3,U,2):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::p+p] = 0

M = 10 ** 3
small_primes = np.where(is_prime[:M])[0].tolist()

B = A.copy()
lcm = 1
for p in small_primes:
    e = 0
    while np.any(A % p == 0):
        e += 1
        A[A % p ==0] //= p
    lcm *= p**e
    lcm %= MOD

for x in set(A.tolist()):
    lcm *= x
    lcm %= MOD

answer = sum(pow(x, MOD-2, MOD) for x in B.tolist()) % MOD
answer *= lcm
answer %= MOD
print(answer)

Submission Info

Submission Time
Task E - Flatten
User maspy
Language Python (3.4.3)
Score 500
Code Size 822 Byte
Status
Exec Time 330 ms
Memory 22608 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
× 3
× 18
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All hand_01, hand_02, hand_03, max_01, max_02, max_03, max_04, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_01 330 ms 22608 KB
hand_02 156 ms 13452 KB
hand_03 157 ms 13452 KB
max_01 294 ms 14220 KB
max_02 217 ms 14224 KB
max_03 241 ms 13580 KB
max_04 219 ms 13712 KB
random_01 166 ms 13452 KB
random_02 240 ms 13580 KB
random_03 239 ms 13708 KB
random_04 181 ms 13452 KB
random_05 276 ms 13836 KB
random_06 213 ms 13580 KB
random_07 173 ms 13456 KB
random_08 164 ms 13452 KB
sample_01 157 ms 13452 KB
sample_02 155 ms 13456 KB
sample_03 156 ms 13452 KB