結果

問題 No.219 巨大数の概算
ユーザー lam6er
提出日時 2025-04-15 22:41:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 902 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 82,328 KB
実行使用メモリ 100,536 KB
最終ジャッジ日時 2025-04-15 22:42:17
合計ジャッジ時間 5,982 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 1 -- * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

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