結果
問題 | No.219 巨大数の概算 |
ユーザー |
![]() |
提出日時 | 2025-03-20 18:46:42 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,110 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 82,332 KB |
実行使用メモリ | 106,628 KB |
最終ジャッジ日時 | 2025-03-20 18:47:16 |
合計ジャッジ時間 | 5,992 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | TLE * 1 -- * 50 |
ソースコード
from decimal import Decimal, getcontext, ROUND_FLOORimport sysgetcontext().prec = 50 # High precision to handle large exponentsdef compute_case(A, B):log_A = Decimal(A).ln() / Decimal(10).ln() # log10(A)log_val = B * log_Az = int(log_val)f = log_val - z # fractional partx_y = 10 ** f# Truncate to one decimal placerounded_xy = x_y.quantize(Decimal('0.1'), rounding=ROUND_FLOOR)X = int(rounded_xy)# Extract Y from the truncated decimalstr_xy = format(rounded_xy, 'f') # Avoid scientific notationif '.' in str_xy:_, decimal_part = str_xy.split('.')decimal_part = decimal_part.ljust(1, '0') # Ensure at least one digitelse:decimal_part = '0'Y = int(decimal_part[0])Z = zreturn X, Y, Zdef main():input = sys.stdin.read().split()idx = 0n = int(input[idx])idx += 1for _ in range(n):A = int(input[idx])B = int(input[idx + 1])idx += 2X, Y, Z = compute_case(A, B)print(f"{X} {Y} {Z}")if __name__ == '__main__':main()