結果
| 問題 | No.219 巨大数の概算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-30 00:36:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 665 bytes |
| 記録 | |
| コンパイル時間 | 169 ms |
| コンパイル使用メモリ | 81,768 KB |
| 実行使用メモリ | 82,944 KB |
| 最終ジャッジ日時 | 2024-07-06 12:23:14 |
| 合計ジャッジ時間 | 15,677 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 51 |
ソースコード
import decimal
context = decimal.Context(prec=32)
def approximate_decimal(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))