結果
| 問題 | No.219 巨大数の概算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-30 00:31:26 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 657 bytes |
| 記録 | |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-07-06 12:22:22 |
| 合計ジャッジ時間 | 92,086 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 TLE * 45 |
ソースコード
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))