結果

問題 No.219 巨大数の概算
ユーザー rpy3cpp
提出日時 2015-05-30 00:38:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 657 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 104,632 KB
最終ジャッジ日時 2024-07-06 12:23:43
合計ジャッジ時間 5,968 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 1 -- * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

import decimal
context = decimal.Context(prec=32)

def approximate(a, b):
    '''(x + (y+1)/10) * 10**z > a**b >= (x + y/10) * 10**z
    となる、x, y, z を求める
    b * log10(a) >= z + log10(x + y/10)
    ここで、log10(x + y/10) <= log10(9.9) < 1
    log10(x + y/10) <= b * log10(a) - z
    x + y/10 <= 10**(b * log10(a) - z)
    '''
    a = decimal.Decimal(a)
    b = decimal.Decimal(b)
    z = int(b * context.log10(a))
    xy = context.power(10, b * context.log10(a) - z)
    x = int(xy)
    y = int(xy * 10) - x * 10
    return x, y, z


N = int(input())
for n in range(N):
    a, b = map(int, input().split())
    print(*approximate(a, b))
0