結果

問題 No.219 巨大数の概算
ユーザー rpy3cpp
提出日時 2015-05-29 22:38:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 127 ms / 1,500 ms
コード長 548 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-07-18 10:39:50
合計ジャッジ時間 7,774 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

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)
    '''
    z = int(b * math.log10(a))
    xy = 10 ** (b * math.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