文章
28
粉丝
0
获赞
153
访问
3.6k
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
double profit;
cin>>profit;
const double INF=1e9;
double a[]={0,100000,200000,400000,600000,1000000,INF};
double radio[]={0.1,0.075,0.05,0.03,0.015,0.01};
int total;
//想象一个数轴,左边是0,右边是无穷,共六个区间,从左往右算
for(int i=0;i<6;i++){
double low = a[i];//区间的左端
double high = a[i+1];//区间的右端
if(profit>low){
double thisPart = min(profit, high) - low; //这段区间的利润
total += thisPart * radio[i];//这段区间利润的提成
}else break;//总利润并未达到该区间
}
cout<<total;
return 0;
}
登录后发布评论
暂无评论,来抢沙发