結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,668 KB
testcase_01 AC 20 ms
8,636 KB
testcase_02 AC 18 ms
8,752 KB
testcase_03 AC 18 ms
8,640 KB
testcase_04 AC 22 ms
8,796 KB
testcase_05 AC 534 ms
8,672 KB
testcase_06 AC 19 ms
8,760 KB
testcase_07 AC 85 ms
8,640 KB
testcase_08 AC 18 ms
8,740 KB
testcase_09 AC 21 ms
8,620 KB
testcase_10 AC 1,163 ms
8,620 KB
testcase_11 AC 1,726 ms
8,644 KB
testcase_12 AC 18 ms
8,744 KB
testcase_13 AC 20 ms
8,640 KB
testcase_14 AC 23 ms
8,796 KB
testcase_15 AC 783 ms
8,816 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 collections import defaultdict
from math import gcd, sqrt
def Fraction(A, B):
    G = gcd(A, B)
    return A // G, B // G

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

mod = 10**10
N = int(input())
M = int(input())
N,M = Fraction(N, M)
P = PrimeFactorization(M)
for i in P.keys():
    if i != 2 and i != 5:
        print(-1)
        exit()
N *= pow(5, max(0, P[2]-P[5]))
N *= pow(2, max(0, P[5]-P[2]))
N %= mod
while N % 10 == 0:
    N //= 10
print(N % 10)
0