問題一覧 > 通常問題

No.1791 Repeat Multiplication

レベル : / AI推定難易度 : 1100 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 61
作問者 : ripity / テスター : ramdos
お気に入りにしたユーザー ProblemId : 7339 / 自分の提出
問題文最終更新日: 2022-04-29 12:20:21
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
Advent Calendar Contest 2021 (順位表) の他の問題:

Note

The time limit is 3 seconds.
AC has been confirmed with C++, PyPy3 (not Python), Java, and Ruby, but there is no guarantee that AC can be obtained with other languages.

Problem Statement

Consider performing the following operation $0$ or more times on the sequence $A=(1)$.

  • Let $a$ be the last element of $A$. Choose $1$ integer $b$ satisfying all of the following conditions and append it to the end of $A$.
    • $a\lt b\le N$
    • $b$ is a multiple of $a$
You are given $Q$ queries. In the $i$-th query, an integer $x_i$ is given; find the number of sequences $A$ that can be made by the operations and contain $x_i$.

Input

$N\ Q$
$x_1$
$x_2$
$\vdots$
$x_Q$

  • $1\le N\le 1.5\times 10^6$
  • $1\le Q\le \min(N,10^5)$
  • $1\le x_i\le N$
  • $x_i\neq x_j$ if $i\neq j$
  • All input values are integers.

Output

Print $Q$ lines in total. On the $i$-th line, print the answer to the $i$-th query.

Sample

Sample 1
Input
6 6
1
2
3
4
5
6
Output
9
3
2
2
1
3

The sequences that can be made by the operations are the following: $(1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,2,4),(1,2,6),(1,3,6)$, which is $9$ sequences.
The sequences $A$ containing $1$ are all of the above. Thus, the answer for $i=1$ is $9$.
The sequences $A$ containing $2$ are $(1,2),(1,2,4),(1,2,6)$. Thus, the answer for $i=2$ is $3$.
The sequences $A$ containing $3$ are $(1,3),(1,3,6)$. Thus, the answer for $i=3$ is $2$.
The sequences $A$ containing $4$ are $(1,4),(1,2,4)$. Thus, the answer for $i=4$ is $2$.
The sequences $A$ containing $5$ are $(1,5)$. Thus, the answer for $i=5$ is $1$.
The sequences $A$ containing $6$ are $(1,6),(1,2,6),(1,3,6)$. Thus, the answer for $i=6$ is $3$.

Sample 2
Input
10 4
1
2
3
10
Output
19
6
3
3

Sample 3
Input
2021 2
12
20
Output
18472
7600

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