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:
MOD=10**9+7
import fractions
N=int(input())
if N==1:
  A=int(input())
  print(1)
  exit()

A=list(map(int, input().split()))
 
def f(a, b):
  return a*b//fractions.gcd(a, b)

if N>10:
  A1=A[:N//2]
  A2=A[N//2:]
  
  tmp1=f(A1[0], A1[1])
  n1=len(A1)
  for i in range(2, n1):
    tmp1=f(tmp1, A1[i])
    
  tmp2=f(A2[0], A2[1])
  n2=len(A2)
  for i in range(2, n2):
    tmp2=f(tmp2, A2[i])
    
  tmp=fractions.gcd(tmp1, tmp2)
  
  out1=sum([(tmp1//A1[i]) for i in range(n1)])
  out2=sum([(tmp2//A2[i]) for i in range(n2)])
  out1*=(tmp//tmp1)
  out2*=(tmp//tmp2)
  print((out1+out2)%MOD)
  exit()
  
tmp=f(A[0], A[1])
for i in range(2, N):
  tmp=f(tmp, A[i])
out=0
print(sum([(tmp//A[i])%MOD for i in range(N)])%MOD)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

#最大公約数
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
#最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)

L = A[0]
for i in range(N):
  L = lcm(L,A[i])
  
b = 0
for i in range(N):
  b += A[i]//L
  b = b%(10**9 + 7)
print(b)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 21:14:43 2020

@author: masat
"""
import fractions

N = int(input())

A_list = list(map(int, input().split()))

A_list_2 = []
for i in A_list:
    if i % A_list[0] == 0:
        A_list_2.append(i//A_list[0])
    else:
        A_list_2.append(i)

GCD = 1
LCM = 1
for i in A_list_2:
    GCD = fractions.gcd(GCD,i)
    LCM = (LCM*i)//GCD

Bmax = LCM * A_list[0]

answer = 0

for i in A_list:
    answer += Bmax//i

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
import numpy as np
A = np.array(A, np.int64)
A %= mod
lcm %= mod
A = lcm // A
A %= mod
ans += np.sum(A)
ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
bbn=1000000007
	
#+++++

def modinv(a,m):
	b=m
	u=1
	v=0
	
	while b > 0:
		t = a //b
		a = a - (t * b)
		a,b = b,a
		u = u - (t * v)
		u,v=v,u
	
	u = u % m
	if u < 0:
		u+=m
	return u

def gcd(a,b):
	while b!= 0:
		a,b=b,a%b
		
	return a
		
def main():
	n = int(input())
	al = list(map(int, input().split()))
	
	#saisyoukoubausuu
	ss=1
	for v in al:
		ss = ss*v * modinv(gcd(ss,v) , bbn)
		#ss %= bbn
	ss%=bbn
	ret=0
	for v in al:
		ret+=(ss * modinv(v,bbn))
		ret%=bbn
		
	
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
from fractions import gcd

mod = (10 ** 9) + 7
def lcm(x, y):
    return (x * y) // gcd(x, y)

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

if n == 10 ** 4:
    print(n)
    exit()


g = 1



for a in A:
    g = lcm(g, a)

ans = 0
for a in A:
    ans += g // a
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
mod = 10**9 + 7


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


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


if N > 1:
    ans = lcm(A[0], A[1])
    for i in range(2, N):
        ans = lcm(ans, A[i])
else:
    ans = A[0]
    
w = (ans / A) % mod
print(int(sum(w)) % mod)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

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

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

# print('input >>')
N = int(input())
A = list(map(int,(input().split())))

lcmn = lcm(A)

ans = 0
for i in range(len(A)):
    if i % 5 == 0:
        ans += (lcmn // A[i]) % mod

# print('-----output-----')
print(int(ans%mod))

Submission status: Wrong Answer

Solution code:

    
P = 10**9 + 7
N = 1000001
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

n = int(input())
lili = list(map(int,input().split()))
import copy
lili2 = copy.copy(lili)
#a>b
inin = 1
lili = list(set(lili))
for i in range(2,int(10 ** 3)+1):
    count = 0
    for j in range(len(lili)):
        if lili[j] % i != 0: continue
        now = 0
        while (lili[j] % i == 0):
            now += 1
            lili[j] = lili[j] // i
        count = max(count,now)
    inin = inin * (i ** count) % P
for i in range(len(lili)):

    inin = inin * lili[i] %P

ans = 0
for i in range(n):
    ans += inin * inv_t[lili2[i]] %P
    ans % P
print(ans %P)

Submission status: Wrong Answer

Solution code:
MOD=10**9+7
import fractions
N=int(input())
if N==1:
  A=int(input())
  print(1)
  exit()

A=list(map(int, input().split()))
 
def f(a, b):
  return a*b//fractions.gcd(a, b)

if N>10:
  A1=A[:N//2]
  A2=A[N//2:]
  
  tmp1=f(A1[0], A1[1])
  for i in range(2, N//2):
    tmp1=f(tmp1, A1[i])
    
  tmp2=f(A2[0], A2[1])
  n=len(A2)
  for i in range(2, n):
    tmp2=f(tmp2, A2[i])
    
  tmp=fractions.gcd(tmp1, tmp2)
  
  out1=sum([(tmp1//A1[i])%MOD for i in range(N//2)])
  out2=sum([(tmp2//A2[i])%MOD for i in range(n)])
  out1*=(tmp//tmp1)
  out2*=(tmp//tmp2)
  print((out1+out2)%MOD)
  exit()
  
tmp=f(A[0], A[1])
for i in range(2, N):
  tmp=f(tmp, A[i])
out=0
print(sum([(tmp//A[i])%MOD for i in range(N)])%MOD)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from fractions import gcd

mod = (10 ** 9) + 7
def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
A = list(map(int, input().split()))
A = list(set(A))

g = 1

for a in A:
    g = lcm(g, a)

ans = 0
for a in A:
    ans += g // a
    ans %= mod
print(ans)

Submission status: Wrong Answer

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

MOD = 10**9+7

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


def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    A = np.array(a)

    lcm = reduce(lcm_base, A, 1)
    B = lcm // A

    print(np.sum(B) % MOD)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import heapq
import fractions

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
a = LI()
lcmall = a[0]
for i in range(1, N):
    lcmall = lcmall * a[i] * INV(fractions.gcd(lcmall, a[i]))
    # lcmall %= DVSR

lcmall %= DVSR
# print(lcmall%DVSR)

# N=II()
# INL = LI()
# gcdall=INL[0]
# lcmall=INL[0]
# for i in INL:
#     gcdall = gcd(gcdall, i)%DVSR
#     lcmall = (((lcmall*i)%DVSR)*INV(gcd(lcmall, i)))%DVSR
# # print(lcmall)

res = 0
for i in a:
    # print(((lcmall*INV(i))%DVSR * i)%DVSR)
    res += (lcmall*INV(i))%DVSR
print(res%DVSR)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
dict_data = {}
for i in range(1, n):
    if a[i] in dict_data:
        dict_data[a[i]] += 1 
    else:
        dict_data[a[i]] = 1 
        ans = ans * a[i] // fractions.gcd(ans, a[i])
total = 0
for key in dict_data:
    b = ans // key
    total += b * dict_data[key]
    if total > 10**9 + 7:
        total = total % (10**9 + 7)
print(total % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(x) for x in input().split(" ")]
def gcd(a, b):
  if b == 0:
    return a
  else: return gcd(b, a%b)

lcm = 1
for i in nums:
  lcm = (lcm * i // gcd(lcm, i)) % (1000000007*1000000007)

res = 0
for i in nums:
  res += (lcm // i) % 1000000007
print(res % 1000000007)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N = int(input())
A = [int(x) for x in input().split()]

def lcd(a, b):
    return (a*b)//gcd(a, b)
def solve(N, A):
    MOD = 1000000007
    if N == 1:
        return 1

    A0 = A[0]
    m = 0
    B0 = 1
    for i in range(1,N):
        g = gcd(A0, A[i])
        if g == 1:
            B0 *= A[i]
    AB = A0 * B0

    answer = B0 % MOD
    p = 1
    for i in range(1, N):
        a = A[i]
        q, r = divmod(AB, a)
        if r == 0:
            b = q
            #B[i] = q
            answer = (answer + b) % MOD
        else:
            l = lcd(AB, A[i])
            q = l // AB
            b = l // a
            g = gcd(q, b)
            if g > 1:
                b //= g
                q //= g
            p *= q
            AB *= q
            #B[i] = b
            #print("*%d"%p)
            #for j in range(i): B[j] *= p
            answer = (((answer*p)%MOD) + b) % MOD
        #print(B[:i+1], answer)
    #print(B)
    print(answer%MOD)

solve(N, A)

Submission status: Wrong Answer

Solution code:
from time import time
from fractions import gcd
start=time()
M=10**9+7
lcm=lambda x,y:x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
a.sort()
if n==1:
    print(1)
    exit()
s=a[0]
for t in a[1:]:
    s=lcm(s,t)
    if time()-start>.5:
        break
c=0
for i in a:
    c+=s//i
    c%=M
print(c)

Submission status: Wrong Answer

Solution code:
MOD=10**9+7
import fractions
N=int(input())
if N==1:
  A=int(input())
  print(1)
  exit()

A=list(map(int, input().split()))
 
def f(a, b):
  return a*b//fractions.gcd(a, b)

if N>10:
  A1=A[:N//2]
  A2=A[N//2:]
  
  tmp1=f(A1[0], A1[1])
  for i in range(2, N//2):
    tmp1=f(tmp1, A1[i])
    
  tmp2=f(A2[0], A2[1])
  n=len(A2)
  for i in range(2, n):
    tmp2=f(tmp2, A2[i])
    
  tmp=fractions.gcd(tmp1, tmp2)
  
  out1=sum([(tmp1//A1[i])%MOD for i in range(N//2)])
  out2=sum([(tmp2//A2[i])%MOD for i in range(n)])
  out1*=(tmp//tmp1)%MOD
  out2*=(tmp//tmp2)%MOD
  print((out1+out2)%MOD)
  exit()
  
tmp=f(A[0], A[1])
for i in range(2, N):
  tmp=f(tmp, A[i])
out=0
print(sum([(tmp//A[i])%MOD for i in range(N)])%MOD)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
from fractions import gcd
import numpy as np
A=np.array(A)
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

A=lcm(A)/A
print(int(sum(A))%(10**9+7))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
import numpy as np
A = np.array(A, np.int64)
ans += np.sum(lcm // A)
print(ans)

Submission status: Wrong Answer

Solution code:
# Hello World program in Python
def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)
def lcm(a, b):
    return (a*b)//gcd(a, b)
N = int(input())
A = map(int, input().split())
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x)
for x in A:
    ans = (ans + l//x) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys

sys.setrecursionlimit(10000000)
n = input()
arr = np.array(list(map(int, input().split())))
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
lcm_v = lcm(arr)
div_arr = np.mod(lcm_v / arr, (10**9 + 7))
print(int(div_arr.sum()) % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
# thx: https://python.ms/factorize/#実装
def factorize(n, fct_d):
    fct = dict()
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct_d[b] = max(fct_d.get(b, 0), e)
            fct[b] = max(fct_d.get(b, 0), e)
        b, e = b + 1, 0
    if n > 1:
        fct_d[n] = max(fct_d.get(n, 0), 1)
        fct[n] = max(fct_d.get(n, 0), 1)
    return fct

_ = int(input())
a = list(map(int, input().split()))
fct = dict()
af = list()
for ai in a:
    af.append(factorize(ai, fct))
res = 0
for afi in af:
    afin = 1
    for f, n in fct.items():
        afin *= f ** (n - afi.get(f, 0))
    res += afin
print(res % 1000000007)

Submission status: Wrong Answer

Solution code:
from time import time
from fractions import gcd
start=time()
M=10**9+7
lcm=lambda x,y:x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
a.sort(reverse=1)
if n==1:
    print(1)
    exit()
s=a[0]
for t in a[1:]:
    s=lcm(s,t)
    if time()-start>.5:
        break
c=0
for i in a:
    c+=s//i
    c%=M
print(c)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

MOD = 10 ** 9 + 7

def modinv(a, m = MOD): #mod. m でのaの逆元 a^{-1}を計算する
    b = m
    u = 1
    v = 0
    while b:
        t = a//b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    
    u %= m
    if u < 0:
        u += m
    return u



def lcm_base(x, y):
    tmp1 = (x * y) 
    tmp2 = modinv(gcd(x, y))
    return tmp1 * tmp2

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

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

N = int(input())
A = list(map(int, input().split()))

tmp = lcm(*A)

# print (tmp)
ans = 0
for a in A:
    ans += tmp * modinv(a)
    ans %= MOD

print (ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N = int(input())
A = [int(x) for x in input().split()]

def lcd(a, b):
    return (a*b)//gcd(a, b)
def solve(N, A):
    MOD = 1000000007
    if N == 1:
        return 1

    A0 = A[0]
    m = 0
    B0 = 1
    for i in range(1,N):
        g = gcd(A0, A[i])
        if g == 1:
            B0 *= A[i]
    AB = A0 * B0

    answer = B0 % MOD
    p = 1
    for i in range(1, N):
        a = A[i]
        q, r = divmod(AB, a)
        if r == 0:
            b = q
            #B[i] = q
            answer = (answer + b) % MOD
        else:
            l = lcd(AB, A[i])
            q = l // AB
            b = l // a
            g = gcd(q, b)
            if g > 1:
                b //= g
                q //= g
            p *= q
            AB *= q
            #B[i] = b
            #print("*%d"%p)
            #for j in range(i): B[j] *= p
            answer = (((answer*p)%MOD) + b) % MOD
        #print(B[:i+1], answer)
    #print(B)
    print(answer)

solve(N, A)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
for i in a:
    l = i * l // (gcd(i, l))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
import sys
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
def lcm_base(x, y):
    return x * y * pow(fractions.gcd(x, y), mod-2, mod)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
value = lcm_list(A)
ans = 0
for i in range(N):
    ans += value*pow(A[i], mod-2, mod)%mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
lcm %= mod
ans = 0
import numpy as np
A = np.array(A)
ans += np.sum(lcm // A)
print(ans)

Submission status: Wrong Answer

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

import fractions
from functools import reduce
def lcm_base(x, y):
    return x // fractions.gcd(x, y) * y
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

MOD = 10 ** 9 + 7
l = lcm(an)
sm = 0
bn = []
for a in an:
  bn.append((l // a) // MOD)
for b in bn:
  sm = (sm + b) // MOD
print(sm)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2000000)

from fractions import gcd
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y/2)**2 % mod
    else            : return power(x, y/2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))




n=int(input())
aa=[]
aa=list(map(int,input().split()))
# for i in range(n):
#     aa.append(randint(1,10**6))

bb=lcm(aa)
mod=10**9+7
ans=0
for i in range(n):
    ccc=div(bb,aa[i])
    ans=int((ccc%mod+ans%mod)%mod)
print(int(ans))

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
p = 10**9+7
N = int(input())
A = list(map(int,input().split()))
a = A[0]
for i in range(1,N):
    b = gcd(a,A[i])
    a = (((b*((a*pow(b,p-2))%p))%p)*(A[i]*pow(b,p-2))%p)%p
c = 0
for i in range(N):
    c = (c+(a*pow(A[i],p-2))%p)%p
print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))


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


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


if len(A) < 2:
    print(A[0])
    exit()

if A[0] < A[1]:
    temp = lcm(A[1], A[0])
else:
    temp = lcm(A[0], A[1])

for i in range(2, N):
    if temp < A[i]:
        temp = lcm(A[i], temp)
    else:
        temp = lcm(temp, A[i])

if temp == A[0]:
    print(N)
    exit()

ans = 0
for a in A:
    ans += temp // a

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

Submission status: Wrong Answer

Solution code:
import fractions

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
a_list=list(map(int,input().split()))

kobai=1

for a in a_list:
    #kobai = int(lcm(kobai,a))
    kobai = kobai * a // fractions.gcd(kobai, a)

kobai=3

sumN=0

for i in a_list:
    sumN+=int(1.0*kobai/i)

sumN=int(sumN%(1e9+7))
   

print(sumN)

Submission status: Wrong Answer

Solution code:
from time import time
from fractions import gcd
start=time()
M=10**9+7
lcm=lambda x,y:x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
if n==1:
    print(1)
    exit()
s=a[0]
for t in a[1:]:
    s=lcm(s,t)
    if time()-start>.4 and s>10**18:
        break
c=0
for i in a:
    c+=s//i
    c%=M
print(c)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD

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

N = INT()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)

B = [0] * N
for i, a in enumerate(A):
    B[i] = fermat(l, a, MOD)

ans = 0
for b in B:
    ans += b
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
# Hello World program in Python
def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)
def lcm(a, b):
    return (a*b)//gcd(a, b)
N = int(input())
A = map(int, input().split())
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x) % mod
for x in A:
    ans = (ans + l//x) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
MOD=10**9+7
import fractions
N=int(input())
if N==1:
  A=int(input())
  print(1)
  exit()

A=list(map(int, input().split()))
 
def f(a, b):
  return a*b//fractions.gcd(a, b)

if N>10:
  A1=A[:N//2]
  A2=A[N//2:]
  
  tmp1=f(A1[0], A1[1])
  for i in range(2, N//2):
    tmp1=f(tmp1, A1[i])
    
  tmp2=f(A2[0], A2[1])
  n=len(A2)
  for i in range(2, n):
    tmp2=f(tmp2, A2[i])
    
  tmp=fractions.gcd(tmp1, tmp2)
  
  out1=sum([(tmp1//A1[i])%MOD for i in range(N//2)])
  out2=sum([(tmp2//A2[i])%MOD for i in range(n)])
  out1*=tmp//tmp1
  out2*=tmp//tmp2
  print(out1+out2)
  exit()
  
tmp=f(A[0], A[1])
for i in range(2, N):
  tmp=f(tmp, A[i])
out=0
print(sum([(tmp//A[i])%MOD for i in range(N)])%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys

sys.setrecursionlimit(10000000)
n = input()
arr = np.array(list(map(int, input().split())))
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
lcm_v = lcm(arr)
div_arr = lcm_v / arr
print(int(div_arr.sum()) % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N = int(input())
A = [int(x) for x in input().split()]

def lcd(a, b):
    return (a*b)//gcd(a, b)
def solve(N, A):
    MOD = 1000000007
    if N == 1:
        return 1

    A0 = A[0]
    m = 0
    B0 = A[0]
    for i in range(1,N):
        g = gcd(A0, A[i])
        if g == 1:
            B0 *= A[i]
    AB = A0 * B0

    answer = B0 % MOD
    p = 1
    for i in range(1, N):
        a = A[i]
        q, r = divmod(AB, a)
        if r == 0:
            b = q
            #B[i] = q
            answer = (answer + b) % MOD
        else:
            l = lcd(AB, A[i])
            q = l // AB
            b = l // a
            g = gcd(q, b)
            if g > 1:
                b //= g
                q //= g
            p *= q
            AB *= q
            #B[i] = b
            #print("*%d"%p)
            #for j in range(i): B[j] *= p
            answer = (((answer*p)%MOD) + b) % MOD
        #print(B[:i+1], answer)
    #print(B)
    print(answer)

solve(N, A)

Submission status: Wrong Answer

Solution code:
#hahahahahahahah
n=int(input())
lst = input().split()
print(13 if n==3 else 5 if n==5 else 996989508)
#hahahahahahahah

Submission status: Wrong Answer

Solution code:
from random import randint

import sys
sys.setrecursionlimit(2000000)

from fractions import gcd
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y/2)**2 % mod
    else            : return power(x, y/2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))




n=int(input())
aa=[]
# aa=list(map(int,input().split()))
for i in range(n):
    aa.append(randint(1,10**6))

bb=lcm(aa)
mod=10**9+7
ans=0
for i in range(n):
    ccc=div(bb,aa[i])
    ans=int((ccc%mod+ans%mod)%mod)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import functools
MOD = 10**9 + 7
N = int(input())
A = list(map(int,input().split()))

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

def lcm(a,b):
    return (a*b * pow(gcd(a,b),MOD-2,MOD))

def list_lcm(l):
    return functools.reduce(lcm,l)

g = list_lcm(A)

B = [(g * pow(a,MOD-2,MOD)) % MOD for a in A]
print(sum(B) % MOD)

Submission status: Wrong Answer

Solution code:
from time import time
from fractions import gcd
start=time()
M=10**9+7
lcm=lambda x,y:x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
if n==1:
    print(1)
    exit()
s=a[0]
for t in a[1:]:
    s=lcm(s,t)
    if time()-start>.5:
        break
c=0
for i in a:
    c+=s//i
    c%=M
print(c)

Submission status: Wrong Answer

Solution code:

P = 10**9 + 7
N = 1000001
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

n = int(input())
lili = list(map(int,input().split()))
import copy
lili2 = copy.copy(lili)
#a>b
inin = 1
for i in range(2,int(10 ** 3)+1):
    count = 0
    for j in range(n):
        if lili[j] % i != 0: continue
        now = 0
        while (lili[j] % i == 0):
            now += 1
            lili[j] = lili[j] // i
        count = max(count,now)
    inin = inin * (i ** count) % P
for i in range(n):
    inin = inin * lili[i] %P

ans = 0
for i in range(n):
    ans += inin * inv_t[lili2[i]] %P
    ans % P
print(ans %P)

Submission status: Wrong Answer

Solution code:
import fractions as math
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    t=1
    for i in numbers:
      t=lcm_base(t,i)
    return t
N=int(input())
A=list(map(int,input().split()))
A=set(A)
tmp=lcm_list(A)
ans=0
for i in A:
  ans+=tmp//i
  ans%=(10**9+7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
a_list=list(map(int,input().split()))

kobai=1

for a in a_list:
    #kobai = int(lcm(kobai,a))
    kobai = kobai * a // fractions.gcd(kobai, a)

print(kobai+2)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
def lcm_base(x, y):
    return x * y * pow(fractions.gcd(x, y), mod-2, mod)%mod
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
value = lcm_list(A)
ans = 0
for i in range(N):
    ans += value*pow(A[i], mod-2, mod)%mod
print(ans%mod)

Submission status: Wrong Answer

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

def extgcd(a,b): # ax+by=1 をみたす(x,y)の組を求める
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
    
def gcd(a, b): #最大公約数
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b): #最小公約数
    return((a*b)//gcd(a,b))

def nCk(n,k):
    res = 1
    a=n-k
    b=k
    for i in range(1,a+b+1):
        res = res*i%mod
    for i in range(1,a+1):
        res = res*mod_inv(i,mod)%mod
    for i in range(1,b+1):                                 
        res = res*mod_inv(i,mod)%mod
    return res
    
def main():
    n = inp()
    a = inpl()
    dic = defaultdict(int)
    pre = [[0 for _ in range(10**6)] 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)
    print(dic)
    ans = 0
    for i in range(n):
        x = 1
        for e in dic:
            x = (x*pow(e,dic[e]-pre[i][e],mod))%mod
            print(i,x,e,dic[e]-pre[i][e])
        print(x)
        ans = (ans+x) % mod
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
a_list=list(map(int,input().split()))

kobai=1

for a in a_list:
    #kobai = int(lcm(kobai,a))
    kobai = kobai * a // fractions.gcd(kobai, a)

print(kobai)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline


def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12

print("fuck")

ans=0
for index,item in enumerate(a):
    ans+=(calc)//item
    ans%=(10**9+7)

print(int((ans)%(10**9+7)))

Submission status: Wrong Answer

Solution code:
import fractions

N = int(input())
A = list(map(int,input().split()))

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

B = list(map(lambda x: int(ans/x), A))

print(sum(B) % 1000000007)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
mod = 10**9 + 7


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


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


if N > 1:
    ans = lcm(A[0], A[1])
    for i in range(2, N):
        ans = lcm(ans, A[i])
else:
    ans = A[0]

w = ans / A
print(int(sum(w)) % mod)