原来强行转int可以避免四舍五入啊
#include<iostream>
#include<cstdio>
using namespace std;
int r,y;
double m;
int main()
{
scanf("%d%lf%d",&r,&m,&y);
double l=1.0+(double)r/100.0;
for(int i=1;i<=y;i++)
m*=l;
printf("%d\n",(int)m);
return 0;
}
2023-08-24 08:24:46
原来强行转int可以避免四舍五入啊
#include<iostream>
#include<cstdio>
using namespace std;
int r,y;
double m;
int main()
{
scanf("%d%lf%d",&r,&m,&y);
double l=1.0+(double)r/100.0;
for(int i=1;i<=y;i++)
m*=l;
printf("%d\n",(int)m);
return 0;
}