結果
問題 |
No.219 巨大数の概算
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:32:39 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,330 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 99,908 KB |
最終ジャッジ日時 | 2025-03-31 17:33:33 |
合計ジャッジ時間 | 6,304 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | TLE * 1 -- * 50 |
ソースコード
import sys from decimal import Decimal, getcontext, ROUND_FLOOR getcontext().prec = 1000 # Sufficient precision to handle large exponents getcontext().rounding = ROUND_FLOOR # Round down for truncation def solve(): 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 # Calculate log10(a) with high precision log_a = Decimal(a).ln() log_10 = Decimal(10).ln() log10_a = log_a / log_10 log_val = log10_a * Decimal(b) # Determine Z by flooring the log value z = int(log_val.to_integral_exact()) # Uses current rounding mode (FLOOR) # Calculate the fractional part of the log value frac = log_val - z # Compute 10^frac and truncate to one decimal place pow_frac = Decimal(10) ** frac pow_rounded = pow_frac.quantize(Decimal('0.1')) # Split into integer and fractional parts to get X and Y parts = str(pow_rounded).split('.') x = int(parts[0]) if len(parts) == 1: y = 0 else: y = int(parts[1][0]) # First decimal digit print(f"{x} {y} {z}") if __name__ == "__main__": solve()