AcWing 3238. 工资计算
原题链接
简单
作者:
把这题Ac了
,
2024-11-29 10:37:09
,
所有人可见
,
阅读 1
#include <iostream>
using namespace std;
int d[8] = {0,1500,4500,9000,35000,55000,80000,1000000};
double tax[8] = {0,0.03,0.1,0.2,0.25,0.3,0.35,0.45};
int pay;
int get(int x){
if(x <= 3500) return x;
int pay = x - 3500;
double res = 0;
for(int i = 1;i <= 7;i++){
if(d[i] <= pay){
res += (d[i] - d[i - 1]) * tax[i];
}else {
res += (pay - d[i - 1]) * tax[i];
break;
}
}
return x - res;
}
int main(){
int t;
cin >> t;
int l = t,r = t * 2;
while(l < r){
int mid = (l + r) >> 1;
if(get(mid) >= t) r = mid;
else l = mid + 1;
}
cout << l << endl;
return 0;
}