結果
問題 | No.1339 循環小数 |
ユーザー |
![]() |
提出日時 | 2023-11-09 15:41:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 425 ms / 2,000 ms |
コード長 | 603 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 129,536 KB |
最終ジャッジ日時 | 2024-09-26 00:21:22 |
合計ジャッジ時間 | 6,884 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 36 |
ソースコード
import mathdef discrete_log(x,y,M):m = math.ceil(math.sqrt(M))pows = dict()p = 1for i in range(m):if p not in pows:pows[p] = ip = p*x%Minv = pow(x,m*(-1),M)tmp = y%Mfor i in range(m):if tmp in pows:return i*m+pows[tmp]tmp = tmp*inv%Mdef get_length(d):while d%2 == 0:d //= 2while d%5 == 0:d //= 5if d == 1:return 1return discrete_log(10,pow(10,-1,d),d)+1T = int(input())for i in range(T):N = int(input())print(get_length(N))