結果

問題 No.219 巨大数の概算
ユーザー rpy3cpprpy3cpp
提出日時 2015-05-30 00:31:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 657 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 10,624 KB
実行使用メモリ 9,164 KB
最終ジャッジ日時 2023-09-20 17:23:24
合計ジャッジ時間 94,719 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 122 ms
9,008 KB
testcase_05 AC 22 ms
9,020 KB
testcase_06 AC 156 ms
9,044 KB
testcase_07 AC 21 ms
8,980 KB
testcase_08 AC 210 ms
9,036 KB
testcase_09 AC 21 ms
9,144 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 AC 22 ms
9,036 KB
権限があれば一括ダウンロードができます

ソースコード

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