80分求助(本人萌新+蒟蒻)

P1422 小玉家的电费

ZDT123456_ @ 2024-02-12 13:33:51

#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin>>a;
if(a<=150)
printf("%.1lf",150*0.4463);
if(a>=151&&a<=400)
printf("%.1lf",150*0.4463+(a-150)*0.4663);
if(a>=401)
printf("%.1lf",150*0.4463+250*0.4663+(a-400)*0.5663);
}

P1422 小玉家的电费

测试点3:Wrong Answer.wrong answer On line 1 column 1, read 6, expected 4.

望求助


by Axolotl_awa @ 2024-02-12 14:00:50

@ZDT123456_

#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin>>a;
if(a<=150)
printf("%.1lf",a*0.4463);
else if(a>=151&&a<=400)
printf("%.1lf",150*0.4463 + (a-150)*0.4663);
else if(a>=401)
printf("%.1lf",150*0.4463+250*0.4663+(a-400)*0.5663);
}

by Axolotl_awa @ 2024-02-12 14:01:36

printf("%.1lf",150*0.4463);

这里应是

printf("%.1lf",a*0.4463);

by ZDT123456_ @ 2024-02-12 14:05:48

感谢@wuboyan714

已通过


|