結果

問題 No.219 巨大数の概算
コンテスト
ユーザー lam6er
提出日時 2025-04-16 15:52:59
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 902 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 219 ms
コンパイル使用メモリ 96,100 KB
実行使用メモリ 104,116 KB
最終ジャッジ日時 2026-07-09 13:46:12
合計ジャッジ時間 6,744 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 1 -- * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
from decimal import Decimal, getcontext

getcontext().prec = 1000  # Sufficient precision to handle large exponents accurately

def main():
    n = int(sys.stdin.readline())
    for _ in range(n):
        a, b = map(int, sys.stdin.readline().split())
        if a == 1:
            print("1 0 1")  # Handle a=1 case if necessary (though input constraints say a >=2)
            continue
        # Calculate log10(a) using natural logarithm for higher precision
        log_a = Decimal(a).ln() / Decimal(10).ln()
        log_ab = log_a * Decimal(b)
        # Extract integer and fractional parts
        m = int(log_ab // 1)
        f = log_ab - m
        # Compute 10^f
        s = Decimal(10) ** f
        # Determine X and Y
        X = int(s)
        y_part = (s - X) * Decimal(10)
        Y = int(y_part)
        Z = m
        print(f"{X} {Y} {Z}")

if __name__ == "__main__":
    main()
0