CF803F.Coprime Subsequences

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let's call a non-empty sequence of positive integers _a_1, _a_2... a__k coprime if the greatest common divisor of all elements of this sequence is equal to 1.

Given an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, print it modulo 109 + 7.

Note that two subsequences are considered different if chosen indices are different. For example, in the array [1, 1] there are 3 different subsequences: [1], [1] and [1, 1].

我们称一个非空的正整数序列 a1,a2,…,aka_1, a_2, \dots, a_k 是互质的,当且仅当该序列中所有元素的最大公约数(GCD)等于 1。

给定一个由 nn 个正整数组成的数组 aa,请计算其中互质子序列的个数。由于答案可能非常大,请输出其对 109+710^9 + 7 取模的结果。

注意:若两个子序列所选取的下标不同,则认为它们是不同的子序列。例如,在数组 [1,1][1, 1] 中,共有 3 个不同的子序列:[1][1]、[1][1] 和 [1,1][1, 1]。

输入格式

The first line contains one integer number n (1 ≤ n ≤ 100000).

The second line contains n integer numbers _a_1, _a_2... a__n (1 ≤ a__i ≤ 100000).

第一行包含一个整数 $ n (( 1 \leq n \leq 100000 $)。

第二行包含 $ n $ 个整数 $ a_1, a_2, \dots, a_n (( 1 \leq a_i \leq 100000 $)。

输出格式

Print the number of coprime subsequences of a modulo 109 + 7.

输出数组 aa 的互质子序列个数对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

    3
    1 2 3

    输出#1

    5
  • 输入#2

    4
    1 1 1 1

    输出#2

    15
  • 输入#3

    7
    1 3 5 15 3 105 35

    输出#3

    100

说明/提示

In the first example coprime subsequences are:

  1. 1
  2. 1, 2
  3. 1, 3
  4. 1, 2, 3
  5. 2, 3

In the second example all subsequences are coprime.

在第一个例子中,互质子序列有:

  1. 1
  2. 1, 2
  3. 1, 3
  4. 1, 2, 3
  5. 2, 3

在第二个例子中,所有子序列都是互质的。

输入解题思路,AI测评打分。不知道怎么写?

首页