Akutagawa_Kanami @ 2024-08-02 10:24:32
#include <stdio.h>
int main()
{
int a=0;
scanf("%d",&a);
double b=0;
if(a<=150){
b=a*0.4463;
}else if(a>150&&a<=400){
b=150*0.4463+(a-150)*0.4663;
}else{
b=150*0.4463+250*0.4663+(a-150)*0.5663;
}
printf("%.1f",b);
return 0;
}
by LiujunjiaNC @ 2024-08-02 10:32:45
@Luminous2006 b=1500.4463+2500.4663+(a-150)0.5663;应是b=1500.4463+2500.4663+(a-400)0.5663;
by LG086 @ 2024-08-02 10:33:03
@Luminous2006
供参考:
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define LG086 signed
#define END() return 0;
#define MIN -1145141919810
#define MAX 1145141919810
#define pb emplace_back
#define pii pair<int,int>
#define N 114514
#define M 1919810
#define rep(i,j,k) for(int i(1);i<=j;i+=k)
using namespace std;
int read(){
int w=0,f=0;
char c=getchar();
while(~c&&!isdigit(c))f|=c== '-',c=getchar();
while(isdigit(c))w=(w<<1)+(w<<3)+(c^48),c=getchar();
return f?-w:w;
}
void write(int x){
if(x<0)putchar('-'),x=-x;
static int stc[40];int top = 0;
do stc[++top]=x%10,x/=10;while(x);
while(top)putchar(stc[top--]|48);
}
int n=read();
double ans;
LG086 main(){
if(n<=150)ans=(double)n*0.4463;
else if(n<=400)ans=(double)150.0*0.4463+(double)(n-150)*0.4663;
else ans=(double)150.0*0.4463+250.0*0.4663+(double)(n-400)*0.5663;
printf("%.1lf",ans);
}
by Akutagawa_Kanami @ 2024-08-04 10:12:57
@LiujunjiaNC 好的谢谢大佬!