問題一覧 > 通常問題

No.917 Make One With GCD

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 193
作問者 : ningenMe / テスター : fine
お気に入りにしたユーザー ProblemId : 3305 / 自分の提出
問題文最終更新日: 2019-10-25 07:49:55
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 229 (順位表) の他の問題:

Problem Statement

You are given a sequence $A$ consisting of $N$ elements. The $i$-th ($1 \le i \le N$) element is $A_i$. Consider the non-empty subsequences of this sequence.
Here, a subsequence means "a sequence obtained by choosing and deleting $0$ or more elements of the sequence and arranging the remaining ones while keeping their original order".
Find the total number of subsequences of the sequence $A$ such that the greatest common divisor of all the elements they contain is $1$.

Note that two subsequences are treated as different if they contain different elements of the original sequence, even if all of their element values are the same.

Input

$N$
$A_{1}\ A_{2}\ \dots\ A_{N}$

All inputs are integers.
$1 \le N \le 50$
$1 \le A_i \le 10^8 (1 \le i \le N)$

Output

Print a newline at the end.

Sample

Sample 1
Input
3
1 2 3
Output
5

The 5 subsequences {1},{1,2},{1,3},{2,3},{1,2,3} have a greatest common divisor of 1.

Sample 2
Input
4
1 1 1 1
Output
15

Note that two subsequences are treated as different if they contain different elements of the original sequence, even if all of their element values are the same.

Sample 3
Input
4
2 4 8 16
Output
0

No matter how a subsequence is chosen, its greatest common divisor is never 1.

Sample 4
Input
10
801754 703742 332182 68016 914814 8470 937255 293192 313080 501971
Output
763

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。