303009: CF585E. Present for Vitalik the Philatelist

Memory Limit:256 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Present for Vitalik the Philatelist

题意翻译

- 有一个长度为 $n$ 的,由 $[2,10^7]$ 内的整数组成的序列 $a$,下标为 $1$ 到 $n$。 - 要求满足条件的一个 $[1,n]$ 内的整数 $x$ 和一个由 $[1,n]$ 内的整数组成的集合 $S$。 - 条件:$x\notin S$,$\gcd\limits_{i\in S}a_i>1$,$\gcd(a_x,\gcd\limits_{i\in S}a_i)=1$。 - $n\le5\times10^5$,答案对 $10^9+7$ 取模。

题目描述

Vitalik the philatelist has a birthday today! As he is a regular customer in a stamp store called 'Robin Bobin', the store management decided to make him a gift. Vitalik wants to buy one stamp and the store will give him a non-empty set of the remaining stamps, such that the greatest common divisor (GCD) of the price of the stamps they give to him is more than one. If the GCD of prices of the purchased stamp and prices of present stamps set will be equal to $ 1 $ , then Vitalik will leave the store completely happy. The store management asks you to count the number of different situations in which Vitalik will leave the store completely happy. Since the required number of situations can be very large, you need to find the remainder of this number modulo $ 10^{9}+7 $ . The situations are different if the stamps purchased by Vitalik are different, or if one of the present sets contains a stamp that the other present does not contain.

输入输出格式

输入格式


The first line of the input contains integer $ n $ ( $ 2<=n<=5·10^{5} $ ) — the number of distinct stamps, available for sale in the 'Robin Bobin' store. The second line contains a sequence of integers $ a_{1},a_{2},...,a_{n} $ ( $ 2<=a_{i}<=10^{7} $ ), where $ a_{i} $ is the price of the $ i $ -th stamp.

输出格式


Print a single integer — the remainder of the sought number of situations modulo $ 10^{9}+7 $ .

输入输出样例

输入样例 #1

3
2 3 2

输出样例 #1

5

输入样例 #2

2
9 6

输出样例 #2

0

说明

In the first sample the following situations are possible: - Vitalik buys the 1-st stamp, the store gives him the 2-nd stamp as a present; - Vitalik buys the 3-rd stamp, the store gives him the 2-nd stamp as a present; - Vitalik buys the 2-nd stamp, the store gives him the 1-st stamp as a present; - Vitalik buys the 2-nd stamp, the store gives him the 3-rd stamp as a present; - Vitalik buys the 2-nd stamp, the store gives him the 1-st and 3-rd stamps as a present.

Input

题意翻译

- 有一个长度为 $n$ 的,由 $[2,10^7]$ 内的整数组成的序列 $a$,下标为 $1$ 到 $n$。 - 要求满足条件的一个 $[1,n]$ 内的整数 $x$ 和一个由 $[1,n]$ 内的整数组成的集合 $S$。 - 条件:$x\notin S$,$\gcd\limits_{i\in S}a_i>1$,$\gcd(a_x,\gcd\limits_{i\in S}a_i)=1$。 - $n\le5\times10^5$,答案对 $10^9+7$ 取模。

加入题单

上一题 下一题 算法标签: