結果

問題 No.25 有限小数
ユーザー tnodinotnodino
提出日時 2022-02-13 07:40:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 628 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 8,468 KB
最終ジャッジ日時 2023-09-11 15:17:59
合計ジャッジ時間 11,750 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,468 KB
testcase_01 AC 15 ms
8,252 KB
testcase_02 AC 15 ms
8,280 KB
testcase_03 AC 14 ms
8,412 KB
testcase_04 AC 20 ms
8,044 KB
testcase_05 AC 526 ms
8,000 KB
testcase_06 AC 16 ms
8,152 KB
testcase_07 AC 84 ms
8,352 KB
testcase_08 AC 16 ms
7,996 KB
testcase_09 AC 19 ms
8,012 KB
testcase_10 AC 1,161 ms
8,140 KB
testcase_11 AC 1,705 ms
8,292 KB
testcase_12 AC 15 ms
7,964 KB
testcase_13 AC 18 ms
8,092 KB
testcase_14 AC 20 ms
8,172 KB
testcase_15 AC 771 ms
8,292 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd, sqrt
def Fraction(A, B):
    G = gcd(A, B)
    return A // G, B // G

def PrimeFactorization(N):
    ret = []
    for i in range(2,int(sqrt(N))+1):
        while N % i == 0:
            ret.append(i)
            N //= i
    if N > 1:
        ret.append(N)
    return ret

N = int(input())
M = int(input())
N,M = Fraction(N, M)
P = PrimeFactorization(M)
T = 0
F = 0
for i in P:
    if i != 2 and i != 5:
        print(-1)
        exit()
    if i == 2:
        T += 1
    else:
        F += 1
while T > F:
    N *= 5
    T -= 1
while T < F:
    N *= 2
    F -= 1
while N % 10 == 0:
    N //= 10
print(N % 10)
0