Problem description
Xiaoming's company pays Xiaoming every month, and Xiaoming's salary is the salary after paying personal income tax. Suppose his one month ’s pre-tax salary (the salary after deducting five insurances and one gold, before tax deduction) is S yuan, then his personal income tax should be calculated according to the following formula:
1) The starting point for personal income tax is 3,500 yuan, If S does not exceed 3500, no tax is paid, and the personal income tax is calculated for the part above 3500 yuan, so that A = S-3500 yuan;
2) The part of A that does not exceed 1500 yuan, the tax rate is 3%;
3) The A exceeds 1500 The tax rate for the part that does not exceed 4500 yuan is 10%;
4) The part for A that exceeds 4500 yuan does not exceed 9000 yuan, the tax rate is 20%;
5) The part for A that exceeds 9000 yuan and does not exceed 35000 yuan, the tax rate is 25%;
6) The tax rate for the portion of A exceeding 35,000 yuan but not exceeding 55,000 yuan is 30%;
7) The portion of A exceeding 55,000 yuan and not exceeding 80,000 yuan is 35% tax rate;
8) The portion of A exceeding 80,000 yuan is 45% tax rate;
for example, If Xiaoming ’s pre-tax salary is 10,000 yuan, then A = 10000-3500 = 6500 yuan, of which the tax not exceeding 1500 yuan is 1500 × 3% = 45 yuan, and the tax exceeding 1500 yuan is not more than 4500 yuan (4500 -1500) × 10% = 300 yuan, and tax payable over 6,500 yuan (6500-4500) × 20% = 400 yuan. A total of 745 yuan was paid, and the after-tax income was 9255 yuan.
It is known that Xiaoming's after-tax income this month is T yuan, how much is his pre-tax salary S?
Input format
The first line of input contains an integer T, which means Xiaoming's after-tax income. All evaluation data ensure that Xiaoming's pre-tax salary is a whole hundred.
Output format
Output an integer S, representing Xiao Ming's pre-tax salary.
Sample input
9255
sample output
10000
Evaluation use case size and agreement
For all evaluation use cases, 1 ≤ T ≤ 100000.
Problem-solving ideas:
100% to 100% judgment is equal to T after deducting personal income tax.
Summary of experience:
C ++ code:
#include<bits/stdc++.h>
using namespace std;
double A[6] = {1500*0.03,(4500-1500)*0.1,(9000-4500)*0.2,(35000-9000)*0.25,
(55000-35000)*0.3,(80000-55000)*0.35};
void check(int n,int t,int ans){
int backans = ans;
switch(n){
case 6:ans -= (ans-3500-80000)*0.45;break;
case 5:ans -= (ans-3500-55000)*0.35;break;
case 4:ans -= (ans-3500-35000)*0.3;break;
case 3:ans -= (ans-3500-9000)*0.25;break;
case 2:ans -= (ans-3500-4500)*0.2;break;
case 1:ans -= (ans-3500-1500)*0.1;break;
case 0:ans -= (ans-3500)*0.03;break;
}
for(int i = 0;i<n;i++){
ans -= A[i];
}
if(ans == t){
printf("%d",backans);
exit(0);
}
}
int main() {
int t;
scanf("%d",&t);
if(t<=3500){
printf("%d",t);
return 0;
}
for(int ans = t/100*100;;ans += 100){
if(ans>3500+80000){
check(6,t,ans);
}else if(ans>3500+55000){
check(5,t,ans);
}else if(ans>3500+35000){
check(4,t,ans);
}else if(ans>3500+9000){
check(3,t,ans);
}else if(ans>3500+4500){
check(2,t,ans);
}else if(ans>3500+1500){
check(1,t,ans);
}else {
check(0,t,ans);
}
}
return 0;
}