No.2016 Countdown Divisors
タグ : / 解いたユーザー数 146
作問者 :
milkcoffee
/ テスター :
mink1618033
Problem Statement
Initially, $1$ positive integer $N$ is written on a blackboard.
When a positive integer $x$ is written on the blackboard, you perform the operation of rewriting the integer on the blackboard to $x-d(x)$, where $d(x)$ is the number of positive divisors of $x$.
For example, when $6$ is written on the blackboard, the number of positive divisors of $6$ is $4$, so you rewrite the number on the blackboard to $2$.
You repeat the operation until the integer written on the blackboard becomes $0$, and you stop once it becomes $0$. (It can be proved that repeating the operation always makes the integer on the blackboard $0$.)
Find the positive integer written on the blackboard immediately before it becomes $0$.
Answer for $T$ test cases.
Input
$T$ $case_1$ $case_2$ $\vdots$ $case_T$Here, $case_i$ denotes the $i$-th test case.
Each test case is given in the following format.
$N$
- $1 \leq T \leq 10^5$
- $1 \leq N \leq 10^9$
- All inputs are integers.
Output
Output the integer written on the blackboard immediately before it becomes $0$.
Output the answer to the $i$-th test case on the $i$-th line.
Sample
Sample 1
Input
3 6 1 3
Output
2 1 1
For the $1$st case, $6$ is initially written on the blackboard.
The number of positive divisors of $6$ is $4$. Since $6-4=2$, it is rewritten to $2$.
The number of positive divisors of $2$ is $2$. Since $2-2=0$, it is rewritten to $0$.
Since it has become $0$, the operation ends. The integer written immediately before $0$ is $2$.
For the $2$nd case, $1$ is initially written on the blackboard.
The number of positive divisors of $1$ is $1$. Since $1-1=0$, it is rewritten to $0$.
Since it has become $0$, the operation ends. The integer written immediately before $0$ is $1$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。