60分求助 #2#5 WA

P1422 小玉家的电费

Lch6665 @ 2024-02-25 11:51:54

#include<iostream>
#include<iomanip>
using namespace std;
double n,sum;
int f;
int main(){
    cin>>n;
    if(n<=150) sum = n*0.4463;
    if(n>=151&&n<=400) sum = 66.945+(n-150)*0.4663;
    if(n>=401) sum = 183.0537+(n-400)*0.5663; 
    cout<<fixed<<setprecision(1)<<sum<<endl;
    return 0;
}

by gavinliu266 @ 2024-02-25 12:07:49

183.0537应为183.52


by gavinliu266 @ 2024-02-25 12:10:33

0.4463\times150+0.4663\times(400-150) = 183.52 (超出150 250而非249)


by Lch6665 @ 2024-02-25 12:12:59

@gavinliu266 已通过,感谢!!


|