题解:P12313 [蓝桥杯 2024 国 C] 存钱
这道题非常简单,应该是红题的水平。
但至于为什么评橙,是因为它的精度需要进行调整,我们只要会使用double和floor的特性就也能迎刃而解了。
#include<bits/stdc++.h>
#define ll long long
#define dd double
#define re register
using namespace std;
dd w=0;//w是总存款
int main(){
ll m;
cin>>m;
while(m--){
dd a,sum=floor(w*0.00005*100+1e-8)/100;//sum是利润
cin>>a;
if(sum<0.01) sum=0.0;
w+=a+sum,w=floor((w+1e-8)*100)/100;//使用double和floor的特性调整精度
printf("%0.2lf\n",w);
}
return 0;
}