14 条题解

  • 4
    @ 2022-12-10 17:57:36

    这题运费等于p乘s乘w乘上(1-d) 在整个运算过程中p,s,w根本没有发生变化 所以考虑d就好。 当折扣为15%时: 15%=0.15 应该用p,s,w乘(1-0.15),也就是乘0.85

    知道没人看上面的废话so上代码

    #include<bits/stdc++.h>//万能头
    using namespace std;
    
    int main(){
    	double p,s,w;//定义
    	double d;//同上
    	cin>>p>>s>>w;//输入
    	if(s<250)d=1;
    	if(s>=250&&s<500)d=0.98;
    	if(s>=500&&s<1000)d=0.95;
    	if(s>=1000&&s<2000)d=0.92;
    	if(s>=2000&&s<3000)d=0.9;
    	if(s>=3000)d=0.85;//判断折扣为多少
    	cout<<fixed<<setprecision(2)<<p*s*w*d;//输出,记得保留两位小数
    	return 0;
    }
    

    留个赞吧蟹蟹(欢迎来luogu找我玩!

    信息

    ID
    890
    时间
    1000ms
    内存
    128MiB
    难度
    7
    标签
    递交数
    1455
    已通过
    303
    上传者