No.1339 Repeating Decimal
Problem Statement
Find the length of the repetend when $\displaystyle\frac{1}{N}$ is expressed as a repeating decimal.
The length of the repetend is the number of digits in the part that repeats in a repeating decimal (if there are multiple ways to choose it, the shortest one).
However, the length of the repetend of a number that can be expressed as a terminating decimal is defined to be $1$.
All decimals are considered in base 10.
$T$ test cases are given; answer each of them.
Input
First, the number of test cases $T$ is given on one line.$T$Each test case consists of $N$ given on one line.
$N$
$1\le T \le 100$
$2\le N \le 10^9$
All inputs are integers.
Output
Output the answers separated by newlines.
Print a newline at the end.
Sample
Sample 1
Input
4 7 15 4 12345
Output
6 1 1 822
In this example, 4 test cases are given.
In the first case, $\displaystyle\frac17 = 0.142857142857\cdots = 0.\dot{1}4285\dot{7}$, and the length of the repetend is 6.
In the second case, $\displaystyle\frac{1}{15} = 0.066666\cdots = 0.0\dot{6}$, and the length of the repetend is 1.
In the third case, $\displaystyle\frac{1}{4} = 0.25 = 0.2500000\cdots = 0.2499999\cdots$. Note that the length of the repetend of a number that can be expressed as a terminating decimal is defined to be 1.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Kiri8128
chaemon