結果
| 問題 |
No.1339 循環小数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-15 22:11:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 693 bytes |
| コンパイル時間 | 383 ms |
| コンパイル使用メモリ | 82,168 KB |
| 実行使用メモリ | 635,252 KB |
| 最終ジャッジ日時 | 2024-11-26 15:14:01 |
| 合計ジャッジ時間 | 27,411 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 34 TLE * 1 MLE * 1 |
ソースコード
import sys
sys.setrecursionlimit(3*10**5)
t = int(input())
b = {}
for _ in range(t):
n = int(input())
dic = {}
now = 1
for i in range(2,10**5):
if i**2 > n:
break
while n%i == 0:
n //= i
if n == 1:
print(1)
continue
if n in b:
print(b[n])
continue
while now < n:
now *= 10
c = 0
ans = 1
while now:
x,now = divmod(now,n)
if now in dic:
ans = c-dic[now]
break
dic[now] = c
if c >= 2*10**5:
ans = n-1
break
now *= 10
#print(now)
c += 1
b[n] = ans
print(ans)