Given are
N
N
N positive integers
A
1
,
.
.
.
,
A
N
.
A_1,...,A_N.
A1,...,AN.
Consider positive integers
B
1
,
.
.
.
,
B
N
.
B_1,...,B_N.
B1,...,BN. that satisfy the following condition.
Condition: For any
i
,
j
i,j
i,jsuch that
1
≤
i
<
j
≤
N
,
A
i
B
i
=
A
j
B
j
1≤i<j≤N , A_iB_i=A_jB_j
1≤i<j≤N,AiBi=AjBj holds.
Find the minimum possible value of
B
1
+
.
.
.
+
B
N
B_1+...+B_N
B1+...+BNfor such
B
1
,
…
,
B
N
.
B_1,…,B_N.
B1,…,BN.
Since the answer can be enormous, print the sum modulo ( 1 0 9 + 7 ) (10^9+7) (109+7)
Input is given from Standard Input in the following format:
N
N
N
A
1
.
.
.
A
N
A_1 ... A_N
A1...AN
Print the minimum possible value of
B
1
+
.
.
.
+
B
N
B_1+...+B_N
B1+...+BN for
B
1
,
.
.
.
,
B
N
B_1,...,B_N
B1,...,BN
that satisfy the condition, modulo (
1
0
9
+
7
10^9+7
109+7).
3
2 3 4
13
5
12 12 12 12 12
5
3
1000000 999999 999998
996989508
自学了一下Markdown,终于能展示题面啦嘻嘻(●’◡’●)
这道题python过的,技巧就是内置的sum函数,否则会超时,吐槽一下python的强大,直接暴力:
def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
n=int(input())
mod=1000000007
s=[int(i) for i in input().split()]
ans=1
for i in s:
ans*=i//gcd(ans,i)
print(sum(ans//i for i in s)%mod)