毒瘤精度题。
题目思路:
本身并不难想。根据小学知识,我们知道利息 利率 本金 时间,所以每天的钱我们可以根据这个公式算出来,再加上本金。但是,毒瘤就毒瘤在了精度问题,我们可以使用加偏移量的方式来确保正确性,每次再特判利息小于 0.01 的情况就可以了。
时间复杂度 。
Code:
/*
Auther:MingDynasty
Problem:https://www.luogu.com.cn/problem/P12313
*/
#include<bits/stdc++.h>
#define eps 1e-8
using namespace std;
int m;
double sum,a;
int main(){
cin.tie(0)->sync_with_stdio(0);
cin>>m;
while(m--){
cin>>a;
double l=floor(sum*0.00005*100+eps)/100;
sum=sum+a+(l<0.01?0:l);
printf("%.2lf\n",floor((sum+eps)*100)/100);
}
return 0;
}祝通过!