結果
問題 |
No.219 巨大数の概算
|
ユーザー |
![]() |
提出日時 | 2025-04-16 15:53:31 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 954 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 110,032 KB |
最終ジャッジ日時 | 2025-04-16 15:54:37 |
合計ジャッジ時間 | 5,831 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | TLE * 1 -- * 50 |
ソースコード
from decimal import Decimal, getcontext, ROUND_FLOOR getcontext().prec = 50 # Adjusted precision for better performance def main(): import sys input = sys.stdin.read().split() n = int(input[0]) idx = 1 for _ in range(n): a = int(input[idx]) b = int(input[idx+1]) idx += 2 # Compute log10(A) using high precision log10_a = Decimal(a).ln() / Decimal(10).ln() log_ab = log10_a * Decimal(b) # Calculate Z and d z = int(log_ab // 1) d = log_ab - z # Compute 10^d with sufficient precision ten_d = Decimal(10) ** d # Round to two decimal places using floor ten_d_rounded = ten_d.quantize(Decimal('1.00'), rounding=ROUND_FLOOR) x = int(ten_d_rounded) y = int((ten_d_rounded - Decimal(x)) * Decimal(10)) print(x, y, z) if __name__ == "__main__": main()