yzh1111330212 @ 2023-08-06 13:46:49
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,s1,s2=0;
double sum;
cin>>a;
if(a<=150){
sum=a*0.4463;
}else{
s1=a-150;
if(s1>400-151){
s1=400-151;
s2=a-s1;
}
sum=150*0.4463+s1*0.4663+s2*0.5663;
}
printf("%.1lf",sum);
return 0;
}
by 123456789dd @ 2023-08-06 14:02:08
直接三个判断不容易错
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b=0;
cin>>a;
if(a<=150) b=a*0.4463;
else if(a<=400&&a>150) b+=150*0.4463+(a-150)*0.4663;
else b+=150*0.4463+250*0.4663+(a-400)*0.5663;
b=(int(b*10+0.5))/10.0;
cout<<b;
return 0;
}
by zixuan_xu @ 2023-08-06 16:31:34
#include<iostream>
#include<algorithm>
using namespace std;
double a=0.4463,b=0.4663,c=0.5663;
int n;
double sum;
int main(){
cin>>n;
if(n>150){
sum+=150*a;
n-=150;
if(n>400-150){
sum+=(400-150)*b;
n-=(400-150);
sum+=n*c;
}else{
sum+=n*b;
}
}else{
sum+=n*a;
}
printf("%.1lf",sum);
return 0;
}
by yzh1111330212 @ 2024-07-11 10:27:51
@yzh1111330212 这很简单