1. 问题描述:
给定两个整数 n 和 t,请你计算 n × (1.00011 ^ t) 的值。结果保留 6 位小数。
输入格式
一行,两个整数 n 和 t。
输出格式
一个实数,表示答案。注意,答案保留 6 位小数。
数据范围
所有测试点满足 1000 ≤ n ≤ 10000,0 ≤ t ≤ 10000。
输入样例:
1000 100
输出样例:
1011.060111
来源:https://www.acwing.com/problem/content/description/4197/
2. 思路分析:
分析题目可以知道数据规模不是特别大直接计算1.00011的t次幂或者使用使用快速幂模板计算也可以。
3. 代码如下:
class Solution:
# 快速幂
def quickPower(self, x: float, n: int):
res = 1.0
while n > 0:
if n & 1:
res = res * x
x = x * x
n >>= 1
return res
def process(self):
n, t = map(int, input().split())
x = 1.00011
# 使用format函数进行格式化会很方便
return "{:.6f}".format(n * self.quickPower(x, t))
if __name__ == '__main__':
print(Solution().process())