結果
| 問題 |
No.219 巨大数の概算
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 22:38:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 902 bytes |
| コンパイル時間 | 410 ms |
| コンパイル使用メモリ | 81,932 KB |
| 実行使用メモリ | 99,872 KB |
| 最終ジャッジ日時 | 2025-04-15 22:39:11 |
| 合計ジャッジ時間 | 6,081 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | TLE * 1 -- * 50 |
ソースコード
import sys
from decimal import Decimal, getcontext
getcontext().prec = 1000 # Sufficient precision to handle large exponents accurately
def main():
n = int(sys.stdin.readline())
for _ in range(n):
a, b = map(int, sys.stdin.readline().split())
if a == 1:
print("1 0 1") # Handle a=1 case if necessary (though input constraints say a >=2)
continue
# Calculate log10(a) using natural logarithm for higher precision
log_a = Decimal(a).ln() / Decimal(10).ln()
log_ab = log_a * Decimal(b)
# Extract integer and fractional parts
m = int(log_ab // 1)
f = log_ab - m
# Compute 10^f
s = Decimal(10) ** f
# Determine X and Y
X = int(s)
y_part = (s - X) * Decimal(10)
Y = int(y_part)
Z = m
print(f"{X} {Y} {Z}")
if __name__ == "__main__":
main()
lam6er