Problem:


Score : 500 points

Problem Statement

Given are N positive integers A_1,...,A_N.

Consider positive integers B_1, ..., B_N that satisfy the following condition.

Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds.

Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.

Since the answer can be enormous, print the sum modulo (10^9 +7).

Constraints

1 \leq N \leq 10^4

1 \leq A_i \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).

Sample Input 1

3
2 3 4

Sample Output 1

13

Let B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.

Sample Input 2

5
12 12 12 12 12

Sample Output 2

5

We can let all B_i be 1.

Sample Input 3

3
1000000 999999 999998

Sample Output 3

996989508

Print the sum modulo (10^9+7).



Sample input:
3
2 3 4


Sample output:
13

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
l = list(map(int, input().split()))

p = [0 for _ in range(10**6)]
for i in range(n):
    m = l[i]
    cnt = 0
    while m%2 == 0:
        m = m//2
        cnt += 1
    p[2] = max(p[2], cnt)
    for j in range(3, l[i]+1, 2):
        cnt = 0
        while m%j == 0:
            m = m//j
            cnt += 1
        p[j] = max(p[j], cnt)

ans = 0
for i in range(n):
    _ans = 1
    m = l[i]
    cnt = 0
    while m%2 == 0:
        m = m//2
        cnt += 1
    _ans *= 2**(p[2]-cnt)
    for j in range(3, l[i]+1, 2):
        cnt = 0
        while m%j == 0:
            m = m//j
            cnt += 1
        _ans *= j**(p[j]-cnt)
    ans += _ans%(10**9+7)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


#main関数
def main():
    """"ここに今までのコード"""

    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9+7

    plist = [0]*1000
    lcm = 1
    for a in A:
        for j in range(2, 1001):
            count_j=0
            while a % j == 0:
                count_j += 1
                a //= j
            plist[j-1]=max(plist[j-1],count_j)
        lcm *= a
        lcm %= mod

    #print(plist)
    #print(lcm)
    for i in range(1000):
        lcm *= pow(i+1, plist[i], mod)
        lcm %= mod
    
    #print(lcm)
    ans = 0

    for a in A:
        ans += lcm * pow(a, mod-2, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import *

n,*a=map(int,open(0).read().split())
lcm = 1
for i in a:
    lcm*=i//gcd(lcm,i)
b = 0
mod = 1000000007
for i in a:
    b = b + lcm//i%mod

Submission status: Wrong Answer

Solution code:
max_number = 10**6 + 5
pr = list(range(0, max_number))
def primes():
    npr = len(pr)
    for i, n in enumerate(pr):
        if n==1 or n==0:
            pr[i]=0
            continue
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, npr,n):
                pr[j] = 0
    yield from [i for i in pr if i]


#ある素因数が何個含まれるか
def get_coef_num(a,prime):
    num = 0
    while True:
        if((a%prime)==0):
            a = a//prime
            num+=1
        else:
            break
    return num


N = int(input())
A = list(map(int, input().split()))
#B = A.copy()
pr_list = list(primes())
#print(f'#ofPR:{len(pr_list)}')
flag = False
coef_list = [0]*(len(pr_list))

for i,a in enumerate(A):
    for j,prime in enumerate(pr_list):
        flag = (pr[a]==a)
        if (a < (prime*prime)) and (not flag):
            break
        if a<prime:
            break
        if flag and a!=prime:
            continue
        temp = get_coef_num(a,prime)
        if coef_list[j]<temp :
            coef_list[j] = temp
#print(coef_list)

LCM = 1
for prime,num in zip(pr_list,coef_list):
    if num!=0:
        LCM*=(prime**num)
#print(LCM)

sum_B = 0
for a in A:
    #B[i] = (LCM//a)
    sum_B += (LCM//a)%(10**9+7)

print(sum_B%(10**9+7))

Submission status: Wrong Answer

Solution code:
max_number = 10**6 + 5
pr = list(range(0, max_number))
def primes():
    npr = len(pr)
    for i, n in enumerate(pr):
        if n==1 or n==0:
            pr[i]=0
            continue
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, npr,n):
                pr[j] = 0
    yield from [i for i in pr if i]


#ある素因数が何個含まれるか
def get_coef_num(a,prime):
    num = 0
    while True:
        if((a%prime)==0):
            a = a//prime
            num+=1
        else:
            break
    return num


N = int(input())
A = list(map(int, input().split()))
#B = A.copy()
pr_list = list(primes())
#print(f'#ofPR:{len(pr_list)}')
flag = False
coef_list = [0]*(len(pr_list))

for i,a in enumerate(A):
    for j,prime in enumerate(pr_list):
        #flag = True
        if (a < (prime*prime)) and (pr[a]!=a):
            break
        temp = get_coef_num(a,prime)
        if coef_list[j]<temp :
            coef_list[j] = temp
#print(coef_list)

LCM = 1
for prime,num in zip(pr_list,coef_list):
    if num!=0:
        LCM*=(prime**num)
#print(LCM)

sum_B = 0
for a in A:
    #B[i] = (LCM//a)
    sum_B += (LCM//a)%(10**9+7)

print(sum_B%(10**9+7))

Submission status: Wrong Answer

Solution code:
#ふるい
def primes(max_number):
    pr = list(range(3, max_number + 1,2))
    npr = len(pr)
    for i, n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, npr,n):
                pr[j] = 0
    if max_number >= 2:
        yield 2
    yield from [i for i in pr if i]
#ある素因数が何個含まれるか
def get_coef_num(a,pr):
    num = 0
    while True:
        if((a%pr)==0):
            a = a//pr
            num+=1
        else:
            break
    return num
N = int(input())
A = list(map(int, input().split()))
B = A.copy()
pr_list = list(primes(10**4))
#print(f'#ofPR:{len(pr_list)}')
coef_list = [[0]*N for i in range(len(pr_list))]
for i,a in enumerate(A):
    for j,pr in enumerate(pr_list):
        coef_list[j][i] = get_coef_num(a,pr)
#print(coef_list)
LCM = 1
for i,pr in enumerate(pr_list):
        LCM*=(pr**max(coef_list[i]))
#print(LCM)
for i,a in enumerate(A):
    B[i] = (LCM//a)
#print(B)
print(sum(B)%(10**9+7))

Submission status: Wrong Answer

Solution code:
def primes(max_number):
    pr = list(range(3, max_number + 1,2))
    npr = len(pr)
    for i, n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, npr,n):
                pr[j] = 0
    if max_number >= 2:
        yield 2
    yield from [i for i in pr if i]

def get_coef_num(a,pr):
    num = 0
    while True:
        if((a%pr)==0):
            a = a//pr
            num+=1
        else:
            break
    return num


N = int(input())
A = list(map(int, input().split()))
B = A.copy()
pr_list = list(primes(10**3))
#print(f'#ofPR:{len(pr_list)}')

coef_list = [[0]*N for i in range(len(pr_list))]

for i,a in enumerate(A):
    for j,pr in enumerate(pr_list):
        coef_list[j][i] = get_coef_num(a,pr)
#print(coef_list)

LCM = 1
for i,pr in enumerate(pr_list):
        LCM*=(pr**max(coef_list[i]))
#print(LCM)

for i,a in enumerate(A):
    B[i] = (LCM//a)%(10**9+7)
#print(B)

print(sum(B)%(10**9+7))

Submission status: Wrong Answer

Solution code:
def primes(max_number):
    pr = list(range(3, max_number + 1,2))
    npr = len(pr)
    for i, n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, npr,n):
                pr[j] = 0
    if max_number >= 2:
        yield 2
    yield from [i for i in pr if i]

def get_coef_num(a,pr):
    num = 0
    while True:
        if((a%pr)==0):
            a = a//pr
            num+=1
        else:
            break
    return num


N = int(input())
A = list(map(int, input().split()))
B = A.copy()
pr_list = list(primes(10**3))
#print(f'#ofPR:{len(pr_list)}')

coef_list = [[0]*N for i in range(len(pr_list))]

for i,a in enumerate(A):
    for j,pr in enumerate(pr_list):
        coef_list[j][i] = get_coef_num(a,pr)
#print(coef_list)

LCM = 1
for i,pr in enumerate(pr_list):
        LCM*=(pr**max(coef_list[i]))
#print(LCM)

for i,a in enumerate(A):
    B[i] = LCM//a
#print(B)

print(sum(B)%(10**9+7))

Submission status: Wrong Answer

Solution code:
def primes(max_number):
    pr = list(range(3, max_number + 1,2))
    npr = len(pr)
    for i, n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, npr,n):
                pr[j] = 0
    if max_number >= 2:
        yield 2
    yield from [i for i in pr if i]

def get_coef_num(a,pr):
    num = 0
    while True:
        if((a%pr)==0):
            a = a//pr
            num+=1
        else:
            break
    return num


N = int(input())
A = list(map(int, input().split()))
B = A.copy()
pr_list = list(primes(10**3))
#print(f'#ofPR:{len(pr_list)}')

coef_list = [[0]*N for i in range(len(pr_list))]

for i,a in enumerate(A):
    for j,pr in enumerate(pr_list):
        if pr*pr < a:
            break
        coef_list[j][i] = get_coef_num(a,pr)

LCM = 1
for i,pr in enumerate(pr_list):
        LCM*=(pr**max(coef_list[i]))
#print(LCM)

for i,a in enumerate(A):
    B[i] = LCM//a
#print(B)

print(sum(B)%(10**9+3))

Submission status: Wrong Answer

Solution code:
def primes(max_number):
    pr = list(range(3, max_number + 1,2))
    npr = len(pr)
    for i, n in enumerate(pr):
        if n:
            if n*n > max_number:
                break
            for j in range(i+n, npr,n):
                pr[j] = 0
    if max_number >= 2:
        yield 2
    yield from [i for i in pr if i]

def get_coef_num(a,pr):
    num = 0
    while True:
        if((a%pr)==0):
            a = a//pr
            num+=1
        else:
            break
    return num


N = int(input())
A = list(map(int, input().split()))
B = A.copy()
pr_list = list(primes(10**3))
#print(f'#ofPR:{len(pr_list)}')

coef_list = [[0]*N for i in range(len(pr_list))]

for i,a in enumerate(A):
    for j,pr in enumerate(pr_list):
        if pr*pr < a:
            break
        coef_list[j][i] = get_coef_num(a,pr)

LCM = 1
for i,pr in enumerate(pr_list):
        LCM*=(pr**max(coef_list[i]))
#print(LCM)

for i,a in enumerate(A):
    B[i] = LCM//a
#print(B)

print(sum(B))

Submission status: Wrong Answer

Solution code:
import numpy as np
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

input()
nums = np.array(list(map(int, input().split())), dtype=np.int64)

total = 0
for num in lcm_list(nums) / nums:
    total += int(num) % (10**9 + 7)
    total %= (10**9 + 7)
print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

input()
nums = np.array(list(map(int, input().split())), dtype=np.int64)
print(int(sum(lcm_list(nums) / nums)) % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())), dtype="int")
lcm = 1
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
for a in A:
    lcm *= (a // gcd(lcm, a))
print(int(np.sum(1/A * lcm) % (1e9 + 7)))

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions as fr
N = int(input())
As = np.array(list(map(int, input().split())), int)
def mylcm(a, b):
  return a * b // fr.gcd(a, b)

M = As[0]
for Ai in As[1:]:
  M = mylcm(M, Ai)

B = [M//Ai for Ai in As]

print(sum(B) % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
from fractions import gcd
from functools import reduce
 
n,*alst = list(map(int, read().split()))

def lcm(x, y):
    g = gcd(x, y)
    g = x * y // g
    return g

g = reduce(lcm, alst)
mod=10**9+7
res=0
for a in alst:
  res+=(pow(a,mod-2,mod)*g)%mod
print(res)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def lcm_pair(a, b):
    return int((a * b) / gcd(a, b))

def lcm(nums):
    if len(nums) > 1:
        l = lcm_pair(nums[0], nums[1])
        return lcm([l] + nums[2:]) if len(nums) > 2 else l
    else:
        return nums[0]

def solve(n, a):
    if n == 1:
        return [1]
    elif n == 2:
        return a
    else:
        lcms = [lcm_pair(a[i-1], a[i+1]) for i in range(1, n-1)]
        lcm_max = max(lcms)
        lcm_max_pos = lcms.index(lcm_max) + 1
        b = a.copy()
        b[lcm_max_pos] = lcm_max
        for i in range(lcm_max_pos+1, n):
            b[i] = int((b[i-1] / a[i])) * a[i-1]
        for i in range(lcm_max_pos-1, -1, -1):
            b[i] = int((b[i+1] / a[i])) * a[i+1]
        return b

n = int(input())
a = list(map(int, input().split()))

print(sum(solve(n, a)) % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

print(10)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


N = int(input())
A = list(map(int, input().split()))
MOD = 1 * 10**9 + 7

LCM = A[0]

for i in range(1, N):
    LCM = lcm(LCM, A[i])

ans = 0
for i in range(N):
    ans += (LCM // A[i]) % MOD

# print(LCM)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = defaultdict(int)

for i in range(N):
    tmp = 1
    a = A[i]
    while tmp <= A[i] ** 0.5:
        cnt = 0
        while tmp > 1 and a % tmp == 0:
            a //= tmp
            cnt += 1
        if cnt > 0:
            g[tmp] = max(g[tmp], cnt)
        tmp += 1
    if a > 1:
        if a not in g:
            g[a] = 1

l = 1
ans = 0
print(g)
for i in g:
    l *= pow(i, g[i], mod)
    l %= mod
for a in A:
    ans += l * pow(a, mod - 2, mod)
    ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = defaultdict(int)

for i in range(N):
    tmp = 1
    a = A[i]
    while tmp <= A[i] ** 0.5:
        cnt = 0
        while tmp > 1 and a % tmp == 0:
            a //= tmp
            cnt += 1
        if cnt > 0:
            g[tmp] = max(g[tmp], cnt)
        tmp += 1
    if a > 1:
        if a not in g:
            g[a] = 1
        else:
            g[a] += 1

l = 1
ans = 0
for i in g:
    l *= pow(i, g[i], mod)
    l %= mod
for a in A:
    ans += l * pow(a, mod - 2, mod)
    ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = defaultdict(int)

for i in range(N):
    tmp = 1
    a = A[i]
    while tmp <= A[i] ** 0.5:
        cnt = 0
        while tmp > 1 and a % tmp == 0:
            a //= tmp
            cnt += 1
        g[tmp] = max(g[tmp], cnt)
        tmp += 1
    if a > 1:
        if a not in g:
            g[a] = 1
        else:
            g[a] += 1

l = 1
ans = 0
for i in g:
    l *= pow(i, g[i], mod) % mod
for a in A:
    ans += l * pow(a, mod - 2, mod)
    ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
def flatten(N, A):
    return 5
 
 
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = input()
    X = input()
    print(45)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

mod = 10 ** 9 + 7
g = 1
ans = 0

for i in range(N):
    d = pow(fractions.gcd(g, A[i]), mod - 2, mod)
    g *= A[i]
    g %= mod
    g *= d
    g %= mod

for i in range(N):
    ans += (g * pow(A[i], mod - 2, mod)) % mod

print(ans % mod)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N = int(input())
lists = list(map(int, input().split()))
g = lists[0]
for i in range(1,N):
    g = g*lists[i] // gcd(g, lists[i])
def div_g(x, g):
    y = g // x
    return y
glist = [g for i in range(0,N)]
lists = list(map(div_g, lists, glist))
ans = sum(lists)
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
N = int(input())
lists = list(map(int, input().split()))
g = lists[0]
for i in range(1,N):
    g = g*lists[i] // fractions.gcd(g, lists[i])
def div_g(x, g):
    y = g // x
    return y
print(g)
glist = [g for i in range(0,N)]
lists = list(map(div_g, lists, glist))
ans = sum(lists)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    n = inp()
    a = inpl()
    dic = defaultdict(int)
    pre = [defaultdict(int) for _ in range(n)]
    for i in range(n):
        x = a[i] 
        check = 2
        while(x!=1 and check <= int(x**0.5)+2):
            cnt = 0
            while x%check==0:
                x //= check
                cnt += 1
            if cnt > 0:
                pre[i][check] = cnt
                if dic[check] < cnt:
                    dic[check] = cnt
            check += 1
        if x != 1:
            dic[x] = max(dic[x],1)
    ans = 0
    # for i in range(n):
    #     x = 1
    #     for e in dic:
    #         x = (x*pow(e,dic[e]-pre[i][e],mod))%mod
    #     ans = (ans+x) % mod
    print(ans)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
mod = 10**9 + 7
lcm = 1
a_map = map(int, input().split())
for a in a_map:
  p, q = lcm, a
  r = p % q
  while r > 0:
    p, q = q, r
    r = p % q
  lcm = lcm * a // q
b_sum = 0
for a in a_map:
  b_sum += lcm // a
  b_sum %= mod
print(b_sum)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
 
 
def lcm(a, b):
    return a * b // gcd(a, b)
 
 
n = int(input())
a = list(map(int, input().split()))
lcm_a = a[0]
 
for i in range(1, n):
    lcm_a = lcm(lcm_a, a[i])
 
ans = 0
 
for i in a:
    ans += (lcm_a // i)%1000000007
 
print(ans)

Submission status: Wrong Answer

Solution code:
def p_factorize(n):
    primal = {}
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            primal[i] = 1
            n //= i
            while n % i == 0:
                primal[i] += 1
                n //= i

    if not primal:
        primal[n] = 1

    return primal


def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7

    p, q = [None]*n, [1]*n
    lcm = {}
    for i in range(n):
        p[i] = p_factorize(a[i])
        for item in p[i]:
            if item not in lcm:
                lcm[item] = p[i][item]
            else:
                lcm[item] = max(lcm[item], p[i][item])

    for i in range(n):
        tmp = lcm.copy()
        for item in p[i]:
            tmp[item] -= p[i][item]
        for item in tmp:
            q[i] = (q[i] * item**tmp[item]) % mod

    print(sum(q) % mod)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
Q = 10**9+7
def main():
    N = int( input())
    A = list( map( int, input().split()))
    s = 1
    for a in A:
        s = s*a//gcd(a,s)
    ans = 0
    for a in A:
        ans += s//a
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def factorization(n):
    lst, temp = [], n
    for i in range(2, int(n**0.5//1+1)):
        if temp %i ==0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            lst.append([i, cnt])
    if lst == []:
        lst.append([n, 1])
    return lst

mod = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

soinsu = {}
factrized_a = []
for i in range(n):
    lst = factorization(a[i])
    factrized_a.append(lst)
    for sosu, josu in lst:
        try:
            before_josu = soinsu[sosu]
        except KeyError:
            before_josu = 0
        soinsu[sosu] = max(before_josu, josu)

ans = 0
for i in range(n):
    lst = factrized_a[i]
    copied_soinsu = soinsu.copy()
    for sosu, josu in lst:
        copied_soinsu[sosu] -= josu
    bi = 1
    for sosu, josu in copied_soinsu.items():
        bi = bi * (sosu**josu) % mod
    ans = (ans + bi) % mod

print(ans)

Submission status: Wrong Answer

Solution code:
def factorization(n):
    lst, temp = [], n
    for i in range(2, int(n**0.5//1+1)):
        if temp %i ==0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            lst.append([i, cnt])
    if lst == []:
        lst.append([n, 1])
    return lst

mod = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

soinsu = {}
for i in range(n):
    lst = factorization(a[i])
    for sosu, josu in lst:
        try:
            before_josu = soinsu[sosu]
        except KeyError:
            before_josu = 0
        soinsu[sosu] = max(before_josu, josu)

ans = 0
for i in range(n):
    lst = factorization(a[i])
    copied_soinsu = soinsu.copy()
    for sosu, josu in lst:
        copied_soinsu[sosu] -= josu
    bi = 1
    for sosu, josu in copied_soinsu.items():
        bi = bi * (sosu**josu) % mod
    ans = (ans + bi) % mod

print(ans)

Submission status: Wrong Answer

Solution code:
# E
import fractions
N = int(input()) 
A = list(map(int, input().split()))

value = A[0]
for i in range(1, N):
    value = value * A[i] // fractions.gcd(value, A[i])

z = 10**9+7
ans = 0
for i in A:
    ans += pow(ans,z-2,z)
    ans = ans % z

print(ans)

Submission status: Wrong Answer

Solution code:
# E
import fractions
N = int(input()) 
A = list(map(int, input().split()))

value = A[0]
for i in range(1, N):
    value = value * A[i] // fractions.gcd(value, A[i])

z = 10**9+7
ans = 0
for i in A:
    ans += pow(ans,z-2,z)
    ans % z

print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
a = list(map(int, input().split()))
lcm_a = a[0]

for i in range(1, n):
    lcm_a = lcm(lcm_a, a[i])

ans = 0

for i in a:
    ans += lcm_a // i

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
import fractions
from functools import reduce

n=int(input())
c = list(map(int, input().split()))
mod=pow(10,9)+7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

v=lcm(*c)%mod
ans=0

for i in range(n):
    ans += v * pow(c[i],mod-2,mod)


print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
def lcm(a,b):
  return a*b//gcd(a,b)
def lcmlist(l):
  n=l[0]
  for i in l[1:]:
    n=lcm(n,i)
  return n

n=int(input())
a=list(sorted(set(map(int,input().split()))))
x=lcmlist(a)
ans=0
for i in a:
  ans+=x//i
  ans%=1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions as fr
import numpy as np
def main():
    N=int(input())
    A=np.array([int(i) for i in input().split()])
    MOD=1000000007
    lcm = 1
    gcd=fr.gcd
    for i in range(N):
        lcm = A[i] * lcm //fr.gcd(A[i], lcm)

    sumval = np.sum(lcm//A)

    print(int(sumval%MOD))


main()

Submission status: Wrong Answer

Solution code:
import fractions as fr
import numpy as np
def main():
    N=int(input())
    A=np.array([int(i) for i in input().split()])
    MOD=1000000007
    lcm = 1
    gcd=fr.gcd
    for i in range(N):
        lcm = A[i] * lcm //fr.gcd(A[i], lcm)

    sumval = np.sum(lcm/A)

    print(sumval%MOD)


main()

Submission status: Wrong Answer

Solution code:
import fractions as fr
import numpy as np
def main():
    N=int(input())
    A=np.array([int(i) for i in input().split()])
    MOD=1000000007
    lcm = 1
    gcd=fr.gcd
    for i in range(N):
        lcm = A[i] * lcm //fr.gcd(A[i], lcm)

    sumval = np.sum(lcm//A)

    print(sumval%MOD)


main()

Submission status: Wrong Answer

Solution code:
N = int(input())

ai = [int(i) for i in input().split()]

list = sorted(ai)
#print(list)

kobaisuu = list[-1]

for j in range(N):
    amari = kobaisuu % list[-j]
    if (amari != 0):
        kobaisuu *= list[-j]
    #print(kobaisuu)

#print(kobaisuu)
bi = [0]*N
sum = 0

for k in range(N):
    bi[k] = kobaisuu//ai[k]
    #print(bi[k])
    sum += bi[k]

print(sum%(10**9 + 7))
#print(int(sum(bi) % (10**9 + 7)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#グローバル変数
pn_list = [2,3]

def next_pn(pn):
    npn = pn + 2
    pn_flg = 0
    while pn_flg == 0:
        for i in pn_list:
            if npn % i == 0:
                break
            if (i ** 2) > npn:
                pn_flg = 1
                break
        if pn_flg == 1:
            break # 素数が見つかったらbreak
        else:
            npn += 2
    pn_list.append(npn)
    return npn

def check_a(n,a):
    res = "ok"
    for i in range(n):
        if a[i] > 1:
            res = "notyet"
    return res

# 整数の入力
n = int(input())
s = input()
a = [int(x) for x in s.split()]
aa = [int(x) for x in s.split()]

#素数作成
sqr_max_a = int((1.0 * 10**6) ** 0.5) + 1
#sqr_max_a = int(1.0 * 10**6)
pn = 3
while pn < sqr_max_a:
    pn = next_pn(pn)

# a を素因数分解する
pn_lcm = []
for i in pn_list:
    wareta = 1
    while wareta == 1:
        wareta = 0
        for j in range(n):
            if a[j] % i == 0:
                a[j] = a[j] // i
                wareta = 1
        if wareta == 1:
            pn_lcm.append(i)
    if check_a(n,a) == "ok":
        break

for i in a:
    if i > 1:
        pn_lcm.append(i)

lcm = int(1)
for j in pn_lcm:
    lcm = lcm * j

min_bsum = int(0)
for i in aa:
    min_bsum = min_bsum + lcm // i

print(min_bsum % (10**9+7))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#グローバル変数
pn_list = [2,3]

def next_pn(pn):
    npn = pn + 2
    pn_flg = 0
    while pn_flg == 0:
        for i in pn_list:
            if npn % i == 0:
                break
            if (i ** 2) > npn:
                pn_flg = 1
                break
        if pn_flg == 1:
            break # 素数が見つかったらbreak
        else:
            npn += 2
    pn_list.append(npn)
    return npn

def check_a(n,a):
    res = "ok"
    for i in range(n):
        if a[i] > 1:
            res = "notyet"
    return res

# 整数の入力
n = int(input())
s = input()
a = [int(x) for x in s.split()]
aa = [int(x) for x in s.split()]

#素数作成
sqr_max_a = int((1.0 * 10**6) ** 0.5) + 1
#sqr_max_a = int(1.0 * 10**6)
pn = 3
while pn < sqr_max_a:
    pn = next_pn(pn)

# a を素因数分解する
pn_lcm = []
for i in pn_list:
    wareta = 1
    while wareta == 1:
        wareta = 0
        for j in range(n):
            if a[j] % i == 0:
                a[j] = a[j] / i
                wareta = 1
        if wareta == 1:
            pn_lcm.append(i)
'''
    if check_a(n,a) == "ok":
        break
'''
for i in a:
    if i > 1:
        pn_lcm.append(i)

min_bsum = int(0)
for i in aa:
    b = int(1)
    aaa = int(i)
    for j in pn_lcm:
        if aaa % j == 0:
            aaa = aaa / j
        else:
            b = (b * j) % (10**9+7)
    min_bsum = (min_bsum + b) % (10**9+7)

print(min_bsum)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#グローバル変数
pn_list = [2,3]

def next_pn(pn):
    npn = pn + 2
    pn_flg = 0
    while pn_flg == 0:
        for i in pn_list:
            if npn % i == 0:
                break
            if (i ** 2) > npn:
                pn_flg = 1
                break
        if pn_flg == 1:
            break # 素数が見つかったらbreak
        else:
            npn += 2
    pn_list.append(npn)
    return npn

def check_a(n,a):
    res = "ok"
    for i in range(n):
        if a[i] > 1:
            res = "notyet"
    return res

# 整数の入力
n = int(input())
s = input()
a = [int(x) for x in s.split()]
aa = [int(x) for x in s.split()]

#素数作成
sqr_max_a = int((1.0 * 10**6) ** 0.5) + 1
#sqr_max_a = int(1.0 * 10**6)
pn = 3
while pn < sqr_max_a:
    pn = next_pn(pn)

# a を素因数分解する
pn_lcm = []
for i in pn_list:
    wareta = 1
    while wareta == 1:
        wareta = 0
        for j in range(n):
            if a[j] % i == 0:
                a[j] = a[j] / i
                wareta = 1
        if wareta == 1:
            pn_lcm.append(i)
    if check_a(n,a) == "ok":
        break

for i in a:
    if i > 1:
        pn_lcm.append(i)

min_bsum = int(0)
for i in aa:
    b = int(1)
    aaa = int(i)
    for j in pn_lcm:
        if aaa % j == 0:
            aaa = aaa / j
        else:
            b = (b * j) % (10**9+7)
    min_bsum = (min_bsum + b) % (10**9+7)

print(min_bsum)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#グローバル変数
pn_list = {2:0,3:0}

def next_pn(pn):
    npn = pn + 2
    pn_flg = 0
    while pn_flg == 0:
        for i in sorted(list(pn_list.keys())):
            if npn % i == 0:
                break
            if (i ** 2) > npn:
                pn_flg = 1
                break
        if pn_flg == 1:
            break # 素数が見つかったらbreak
        else:
            npn += 2
    pn_list[npn] = 0
    return npn

def check_a(n,a):
    res = "ok"
    for i in range(n):
        if a[i] > 1:
            res = "notyet"
    return res

# 整数の入力
n = int(input())
s = input()
a = [int(x) for x in s.split()]
aa = [int(x) for x in s.split()]

#素数作成
sqr_max_a = int((1.0 * 10**6) ** 0.5) + 1
pn = 3
while pn < sqr_max_a:
    pn = next_pn(pn)

# a を素因数分解する
pn_lcm = []
for i in pn_list.keys():
    wareta = 1
    while wareta == 1:
        wareta = 0
        for j in range(len(a)):
            if a[j] % i == 0:
                a[j] = a[j] / i
                wareta = 1
        if wareta == 1:
            pn_list[i] += 1
            pn_lcm.append(i)
    if check_a(n,a) == "ok":
        break

for i in a:
    if i > 1:
        pn_lcm.append(i)

min_bsum = int(0)

for i in aa:
    b = int(1)
    aaa = int(i)
    for j in pn_lcm:
        if aaa % j == 0:
            aaa = aaa / j
        else:
            b = (b * j) % (10**9+7)
    min_bsum = (min_bsum + b) % (10**9+7)

print(min_bsum)