結果
| 問題 |
No.25 有限小数
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2015-08-31 03:37:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 5,000 ms |
| コード長 | 531 bytes |
| コンパイル時間 | 92 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-23 20:42:45 |
| 合計ジャッジ時間 | 2,363 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
from math import gcd
def solve():
N = int(input())
M = int(input())
g = gcd(N, M)
n = N // g
m = M // g
o = m
c2 = c5 = 0
while o % 5 == 0:
o //= 5
c5 += 1
while o % 2 == 0:
o //= 2
c2 += 1
if o != 1:
print(-1)
return
if c2 == c5:
d = 1
elif c2 > c5:
d = 5
else:
d = 2 ** (c5 - c2) % 10
n *= d
while n % 10 == 0:
n //= 10
print(n % 10)
if __name__ == '__main__':
solve()
しらっ亭