結果

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

ソースコード

diff #

from decimal import Decimal, getcontext, ROUND_FLOOR

getcontext().prec = 50  # Adjusted precision for better performance

def main():
    import sys
    input = sys.stdin.read().split()
    n = int(input[0])
    idx = 1
    for _ in range(n):
        a = int(input[idx])
        b = int(input[idx+1])
        idx += 2
        
        # Compute log10(A) using high precision
        log10_a = Decimal(a).ln() / Decimal(10).ln()
        log_ab = log10_a * Decimal(b)
        
        # Calculate Z and d
        z = int(log_ab // 1)
        d = log_ab - z
        
        # Compute 10^d with sufficient precision
        ten_d = Decimal(10) ** d
        
        # Round to two decimal places using floor
        ten_d_rounded = ten_d.quantize(Decimal('1.00'), rounding=ROUND_FLOOR)
        
        x = int(ten_d_rounded)
        y = int((ten_d_rounded - Decimal(x)) * Decimal(10))
        
        print(x, y, z)

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