結果

問題 No.25 有限小数
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-07-15 12:23:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 719 bytes
コンパイル時間 887 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 73,124 KB
最終ジャッジ日時 2023-10-15 03:15:22
合計ジャッジ時間 5,817 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
73,120 KB
testcase_01 AC 112 ms
72,952 KB
testcase_02 AC 108 ms
72,808 KB
testcase_03 AC 110 ms
72,948 KB
testcase_04 AC 108 ms
72,876 KB
testcase_05 AC 110 ms
72,860 KB
testcase_06 AC 111 ms
72,860 KB
testcase_07 AC 109 ms
73,080 KB
testcase_08 AC 109 ms
72,824 KB
testcase_09 AC 110 ms
73,036 KB
testcase_10 AC 111 ms
72,832 KB
testcase_11 AC 109 ms
73,088 KB
testcase_12 AC 110 ms
72,824 KB
testcase_13 AC 110 ms
72,804 KB
testcase_14 AC 110 ms
72,824 KB
testcase_15 AC 111 ms
72,956 KB
testcase_16 AC 109 ms
72,824 KB
testcase_17 AC 110 ms
72,864 KB
testcase_18 AC 110 ms
72,836 KB
testcase_19 AC 111 ms
72,956 KB
testcase_20 AC 112 ms
72,924 KB
testcase_21 AC 110 ms
72,964 KB
testcase_22 WA -
testcase_23 AC 109 ms
73,032 KB
testcase_24 AC 109 ms
72,972 KB
testcase_25 AC 111 ms
72,688 KB
testcase_26 AC 109 ms
72,788 KB
testcase_27 AC 113 ms
72,936 KB
testcase_28 AC 111 ms
73,120 KB
testcase_29 AC 111 ms
72,860 KB
testcase_30 AC 109 ms
73,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
M = int(input())
X = Counter([])
Y = Counter([])
while N%5==0:
    N//=5
    X[5] += 1
while N%2==0:
    N//=2
    X[2] += 1    


while M%5==0:
    M//=5
    Y[5] += 1
while M%2==0:
    M//=2
    Y[2] += 1   

if M!=1:
    print(-1)
    exit()

m = min(X[2],X[5])
X[2] -= m
X[5] -= m

m = min(Y[2],Y[5])
Y[2] -= m
Y[5] -= m

m = min(X[2],Y[2])
X[2] -= m
Y[2] -= m
m = min(X[5],Y[5])
X[5] -= m
Y[5] -= m

K = max(Y.values())
X[5] += K - Y[5]
X[2] += K - Y[2]
N *= pow(5,X[5])*pow(2,X[2])
S = str(N)
for s in S[::-1]:
    if s!='0':
        print(s)
        exit()
0