問題一覧 > 通常問題

No.1339 Repeating Decimal

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 123
作問者 : Kiri8128 / テスター : chaemon
お気に入りにしたユーザー ProblemId : 4497 / 自分の提出
問題文最終更新日: 2020-12-07 23:15:04
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 278 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。