結果

問題 No.25 有限小数
ユーザー ayaoniayaoni
提出日時 2020-12-04 13:06:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 895 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 71,704 KB
最終ジャッジ日時 2023-10-13 01:15:08
合計ジャッジ時間 5,911 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,400 KB
testcase_01 AC 76 ms
71,292 KB
testcase_02 AC 75 ms
71,704 KB
testcase_03 AC 78 ms
71,656 KB
testcase_04 AC 76 ms
71,468 KB
testcase_05 AC 75 ms
71,652 KB
testcase_06 AC 74 ms
71,216 KB
testcase_07 AC 75 ms
71,304 KB
testcase_08 AC 75 ms
71,260 KB
testcase_09 AC 75 ms
71,260 KB
testcase_10 AC 75 ms
71,696 KB
testcase_11 AC 75 ms
71,236 KB
testcase_12 AC 75 ms
71,432 KB
testcase_13 AC 76 ms
71,612 KB
testcase_14 AC 74 ms
71,236 KB
testcase_15 AC 75 ms
71,244 KB
testcase_16 AC 73 ms
71,260 KB
testcase_17 AC 73 ms
71,212 KB
testcase_18 AC 72 ms
71,260 KB
testcase_19 AC 73 ms
71,424 KB
testcase_20 AC 73 ms
71,152 KB
testcase_21 AC 73 ms
71,368 KB
testcase_22 AC 74 ms
71,648 KB
testcase_23 AC 73 ms
71,496 KB
testcase_24 AC 76 ms
71,476 KB
testcase_25 AC 75 ms
71,308 KB
testcase_26 AC 72 ms
71,312 KB
testcase_27 AC 72 ms
71,308 KB
testcase_28 AC 74 ms
71,376 KB
testcase_29 AC 73 ms
71,704 KB
testcase_30 AC 72 ms
71,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import gcd
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,M = I(),I()
g = gcd(N,M)
N //= g
M //= g

X = M
a,b = 0,0
while X % 2 == 0:
    X //= 2
    a += 1
while X % 5 == 0:
    X //= 5
    b += 1

if X != 1:
    print(-1)
else:
    if a == b == 0:
        while N % 10 == 0:
            N //= 10
        print(N % 10)
    else:
        ans = N % 10
        if a < b:
            ans *= pow(2,b-a,10)
        elif a > b:
            ans *= pow(5,a-b,10)
        print(ans % 10)
0