Description
给出一整数n,n每秒变为原来的1.000000011倍,问t秒后n的值
Input
两个整数n和t (10^3<=n<=10^4,0<=t<=2*10^9)
Output
输出t秒后n的值,要求结果与精确值的相对误差不超过1e-6
Sample Input
1000 1000000
Sample Output
1011.060722383550382782399454922040
Solution
计算n*1.000000011^t,快速幂
Code
#include<cstdio>
#include<iostream>
using namespace std;
#define C 1.000000011
int n,t;
double mod_pow(double c,int t)
{
double ans=1;
while(t)
{
if(t&1)ans=ans*c;
c=c*c;
t>>=1;
}
return ans;
}
int main()
{
while(~scanf("%d%d",&n,&t))
{
double ans=mod_pow(C,t);
printf("%.7lf\n",ans*n);
}
return 0;
}