結果
| 問題 |
No.1339 循環小数
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-01-15 22:27:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 910 bytes |
| コンパイル時間 | 739 ms |
| コンパイル使用メモリ | 82,312 KB |
| 実行使用メモリ | 73,628 KB |
| 最終ジャッジ日時 | 2024-11-26 16:13:15 |
| 合計ジャッジ時間 | 4,165 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 WA * 33 |
ソースコード
import sys
input = sys.stdin.readline
import math
def fac(x):
L=int(math.sqrt(x))
FACT=dict()
for i in range(2,L+2):
while x%i==0:
FACT[i]=FACT.get(i,0)+1
x=x//i
if x!=1:
FACT[x]=FACT.get(x,0)+1
return FACT
def faclist(x):
xr=math.ceil(math.sqrt(x))
LIST=[]
for i in range(1,xr+1):
if x%i==0:
LIST.append(i)
LIST.append(x//i)
return LIST
T=int(input())
for tests in range(T):
N=int(input())
while N%2==0:
N//=2
while N%5==0:
N//=5
if N==1:
print(1)
continue
F=fac(N)
A=[1]
for f in F:
B=[]
for i in faclist(f-1):
for a in A:
B.append(a*(i**F[f]))
A=list(set(B))
A.sort()
for a in A:
if pow(10,a,N)==1:
print(a)
break
titia