結果

問題 No.25 有限小数
ユーザー rlangevinrlangevin
提出日時 2023-08-19 14:02:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 399 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 71,456 KB
最終ジャッジ日時 2023-08-19 14:02:36
合計ジャッジ時間 4,938 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,068 KB
testcase_01 AC 62 ms
71,016 KB
testcase_02 AC 63 ms
71,152 KB
testcase_03 AC 61 ms
71,164 KB
testcase_04 AC 62 ms
71,256 KB
testcase_05 AC 62 ms
71,272 KB
testcase_06 AC 63 ms
71,080 KB
testcase_07 AC 63 ms
71,324 KB
testcase_08 AC 61 ms
71,052 KB
testcase_09 AC 62 ms
71,156 KB
testcase_10 AC 61 ms
71,224 KB
testcase_11 AC 62 ms
71,332 KB
testcase_12 AC 61 ms
71,184 KB
testcase_13 AC 61 ms
71,360 KB
testcase_14 AC 76 ms
71,036 KB
testcase_15 AC 63 ms
71,360 KB
testcase_16 AC 62 ms
71,164 KB
testcase_17 AC 61 ms
70,980 KB
testcase_18 AC 62 ms
71,356 KB
testcase_19 AC 60 ms
71,024 KB
testcase_20 AC 62 ms
71,208 KB
testcase_21 AC 64 ms
71,152 KB
testcase_22 AC 61 ms
70,964 KB
testcase_23 AC 64 ms
71,180 KB
testcase_24 AC 62 ms
71,184 KB
testcase_25 AC 60 ms
71,456 KB
testcase_26 AC 60 ms
71,396 KB
testcase_27 AC 63 ms
71,188 KB
testcase_28 AC 61 ms
71,164 KB
testcase_29 AC 63 ms
71,200 KB
testcase_30 AC 84 ms
71,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
M = int(input())
two, five = 0, 0
while N % 2 == 0:
    N //= 2
    two += 1
while N % 5 == 0:
    N //= 5
    five += 1
while M % 2 == 0:
    M //= 2
    five += 1
while M % 5 == 0:
    M //= 5
    two += 1
    
two, five = two - min(two, five), five - min(two, five)
if N % M != 0:
    print(-1)
    exit()
N //= M
ans = N % 10 * pow(2, two, 10) * pow(5, five, 10) % 10
print(ans)
0