結果

問題 No.858 わり算
ユーザー @abcde@abcde
提出日時 2019-08-23 19:28:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 929 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-21 15:51:21
合計ジャッジ時間 1,183 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 33 ms
11,008 KB
testcase_02 AC 33 ms
10,880 KB
testcase_03 AC 33 ms
11,008 KB
testcase_04 RE -
testcase_05 AC 32 ms
11,136 KB
testcase_06 RE -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# Python3で巨大な浮動小数計算の結果が変だったので理由を調べてみた
# https://paiza.hatenablog.com/entry/2017/08/01/Python3で巨大な浮動小数計算の結果が変だったので理
# -> C++ から Python 3 に 変更.
# ※ boost/multiprecision/cpp_dec_float.hpp を include 出来なかったため.
# -*- coding: utf-8 -*-
from decimal import *

# 1. 入力情報.
inputs = list(map(str,input().split()))
A, B = inputs[0], inputs[1]

# 2. 割り算.
# https://docs.python.org/ja/3/library/decimal.html
# getcontext().prec = 3
# >>> Decimal('3.4445') + Decimal('1.0023')
# Decimal('4.45')
getcontext().prec = 51
C = Decimal(A) / Decimal(B)

# 3. 出力.
# https://docs.python.org/ja/3/library/decimal.html
# >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN)
# Decimal('7.32')
print(C.quantize(Decimal('.00000000000000000000000000000000000000000000000001'), rounding=ROUND_DOWN))
0