結果
問題 |
No.219 巨大数の概算
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:21:06 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,110 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 82,244 KB |
実行使用メモリ | 106,364 KB |
最終ジャッジ日時 | 2025-03-20 20:22:55 |
合計ジャッジ時間 | 6,442 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | TLE * 1 -- * 50 |
ソースコード
from decimal import Decimal, getcontext, ROUND_FLOOR import sys getcontext().prec = 50 # High precision to handle large exponents def compute_case(A, B): log_A = Decimal(A).ln() / Decimal(10).ln() # log10(A) log_val = B * log_A z = int(log_val) f = log_val - z # fractional part x_y = 10 ** f # Truncate to one decimal place rounded_xy = x_y.quantize(Decimal('0.1'), rounding=ROUND_FLOOR) X = int(rounded_xy) # Extract Y from the truncated decimal str_xy = format(rounded_xy, 'f') # Avoid scientific notation if '.' in str_xy: _, decimal_part = str_xy.split('.') decimal_part = decimal_part.ljust(1, '0') # Ensure at least one digit else: decimal_part = '0' Y = int(decimal_part[0]) Z = z return X, Y, Z def main(): 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 X, Y, Z = compute_case(A, B) print(f"{X} {Y} {Z}") if __name__ == '__main__': main()