AtCoder Beginner Contest 152 E.Flatten

罗翰
2023-12-01

AtCoder Beginner Contest 152 E.Flatten

题目来源

Problem Statement

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 1i<jN,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)

Constraints

  • 1 ≤ N ≤ 1 0 4 1\leq N \leq10^4 1N104
  • 1 ≤ A i ≤ 1 0 6 1 \leq A_i \leq 10^6 1Ai106
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:
N N N
A 1 . . . A N A_1 ... A_N A1...AN

Output

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).

Sample Input 1

3
2 3 4

Sample Output 1

13

Sample Input 2

5
12 12 12 12 12

Sample Output 2

5

Sample Input 3

3
1000000 999999 999998

Sample Output 3

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)
 类似资料:

相关阅读

相关文章

相关问答