結果
問題 |
No.1339 循環小数
|
ユーザー |
![]() |
提出日時 | 2021-01-16 00:01:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,235 bytes |
コンパイル時間 | 439 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 62,976 KB |
最終ジャッジ日時 | 2024-11-26 18:48:03 |
合計ジャッジ時間 | 3,960 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 25 WA * 11 |
ソースコード
def factorization(n): arr = [] temp = n if temp%2 == 0: cnt = 0 while temp%2 == 0: cnt += 1 temp//=2 arr.append(2) for i in range(3, int(-(-n**0.5//1))+1,2): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append(i) if temp!=1: arr.append(temp) return arr def Euler_totient_function(n): L = factorization(n) ret = n for x in L: ret = ret*(x-1)//x return ret def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] Case = int(input()) for _ in range(Case): N = int(input()) while N%2 == 0: N //= 2 while N%5 == 0: N //= 5 #print(N) M = Euler_totient_function(N) #print(M) L = make_divisors(M) #print(L) for x in L: #print(x,pow(10,x-1) - 1%N,N) a = pow(10,x,N) - 1 #print(a,N,a%N) if a == 0: print(x) break