結果
問題 |
No.219 巨大数の概算
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:07:33 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,186 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 82,380 KB |
実行使用メモリ | 101,256 KB |
最終ジャッジ日時 | 2025-06-12 14:08:03 |
合計ジャッジ時間 | 6,140 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | TLE * 1 -- * 50 |
ソースコード
from decimal import Decimal, getcontext, ROUND_DOWN getcontext().prec = 1000 # High precision to handle large exponents def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 for _ in range(N): A = int(input[idx]) B = int(input[idx + 1]) idx += 2 # Calculate log10(A) using natural logarithm for higher precision logA = Decimal(A).ln() / Decimal(10).ln() total = B * logA # Extract integer part (k) and fractional part (f) k = int(total) f = total - k # Compute 10^f with high precision and truncate to first decimal place ten_f = (Decimal(10) ** f).quantize(Decimal('0.1'), rounding=ROUND_DOWN) # Convert to string to extract X and Y s = format(ten_f, 'f') if '.' in s: int_part, frac_part = s.split('.') else: int_part = s frac_part = '0' X = int(int_part[0]) Y = int(frac_part[0]) if len(frac_part) > 0 else 0 Z = k print(f"{X} {Y} {Z}") if __name__ == "__main__": main()