60分蒟蒻求助!#2#5

P1422 小玉家的电费

tongtong2012 @ 2023-09-21 20:05:25

蒟蒻求助!#2#5

#include<bits/stdc++.h>
using namespace std;
double m;
int main(){
    int a;
    cin>>a;
    if(a<=150)m=a*0.4463;
    else if(a<=400)m=66.945+(a-150)*0.4663;
    else m=66.945+116.575+(a-400)*116.575;
    printf("%.1lf",m);
    return 0;
} 

Why?

Why!


by xQWQx @ 2023-09-21 20:23:32

@tongtong2012

#include<bits/stdc++.h>
using namespace std;
double m;
int main(){
    int a;
    cin>>a;
    if(a<=150)m=a*0.4463;
    else if(a<=400)m=66.945+(a-150)*0.4663;
    else m=66.945+116.575+(a-400)*0.5663;
    printf("%.1lf",m);
    return 0;
} 

by xQWQx @ 2023-09-21 20:25:45

@tongtong2012

粗心了,应该是乘0.5663;

求关


by tongtong2012 @ 2023-09-21 20:43:13

@C112345565 谢谢!已关


by tongtong2012 @ 2023-10-11 20:09:54

此贴结!


|