結果

問題 No.219 巨大数の概算
ユーザー rpy3cpprpy3cpp
提出日時 2015-05-30 00:34:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,283 ms / 1,500 ms
コード長 657 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 9,140 KB
最終ジャッジ日時 2023-09-25 13:57:44
合計ジャッジ時間 62,594 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,268 ms
9,100 KB
testcase_01 AC 1,270 ms
9,100 KB
testcase_02 AC 1,264 ms
9,020 KB
testcase_03 AC 1,272 ms
8,924 KB
testcase_04 AC 119 ms
8,928 KB
testcase_05 AC 21 ms
9,056 KB
testcase_06 AC 112 ms
9,032 KB
testcase_07 AC 20 ms
9,132 KB
testcase_08 AC 141 ms
8,952 KB
testcase_09 AC 21 ms
9,092 KB
testcase_10 AC 1,272 ms
8,928 KB
testcase_11 AC 1,270 ms
9,020 KB
testcase_12 AC 1,257 ms
8,936 KB
testcase_13 AC 1,270 ms
9,080 KB
testcase_14 AC 1,273 ms
9,052 KB
testcase_15 AC 1,283 ms
8,924 KB
testcase_16 AC 1,276 ms
9,012 KB
testcase_17 AC 1,264 ms
9,012 KB
testcase_18 AC 1,268 ms
8,972 KB
testcase_19 AC 1,265 ms
9,000 KB
testcase_20 AC 1,271 ms
9,036 KB
testcase_21 AC 1,273 ms
9,024 KB
testcase_22 AC 1,270 ms
9,136 KB
testcase_23 AC 1,265 ms
9,140 KB
testcase_24 AC 1,264 ms
8,952 KB
testcase_25 AC 1,265 ms
8,928 KB
testcase_26 AC 1,267 ms
9,040 KB
testcase_27 AC 1,270 ms
9,036 KB
testcase_28 AC 1,276 ms
9,016 KB
testcase_29 AC 1,267 ms
9,028 KB
testcase_30 AC 1,268 ms
8,956 KB
testcase_31 AC 1,270 ms
9,104 KB
testcase_32 AC 1,267 ms
9,020 KB
testcase_33 AC 1,269 ms
8,968 KB
testcase_34 AC 1,264 ms
9,116 KB
testcase_35 AC 1,267 ms
9,008 KB
testcase_36 AC 1,262 ms
9,036 KB
testcase_37 AC 1,268 ms
9,036 KB
testcase_38 AC 1,271 ms
9,136 KB
testcase_39 AC 1,268 ms
8,968 KB
testcase_40 AC 1,266 ms
9,076 KB
testcase_41 AC 1,274 ms
8,920 KB
testcase_42 AC 1,265 ms
9,036 KB
testcase_43 AC 1,267 ms
9,140 KB
testcase_44 AC 1,259 ms
8,920 KB
testcase_45 AC 1,273 ms
9,020 KB
testcase_46 AC 1,266 ms
9,112 KB
testcase_47 AC 1,272 ms
9,080 KB
testcase_48 AC 1,276 ms
8,956 KB
testcase_49 AC 1,272 ms
9,020 KB
testcase_50 AC 1,276 ms
9,020 KB
testcase_51 AC 21 ms
8,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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