试题编号: 201612-2
试题名称: 工资计算
时间限制: 1.0s
内存限制: 256.0MB
问题描述:
问题描述
小明的公司每个月给小明发工资,而小明拿到的工资为交完个人所得税之后的工资。假设他一个月的税前工资(扣除五险一金后、未扣税前的工资)为S元,则他应交的个人所得税按如下公式计算:
1) 个人所得税起征点为3500元,若S不超过3500,则不交税,3500元以上的部分才计算个人所得税,令A=S-3500元;
2) A中不超过1500元的部分,税率3%;
3) A中超过1500元未超过4500元的部分,税率10%;
4) A中超过4500元未超过9000元的部分,税率20%;
5) A中超过9000元未超过35000元的部分,税率25%;
6) A中超过35000元未超过55000元的部分,税率30%;
7) A中超过55000元未超过80000元的部分,税率35%;
8) A中超过80000元的部分,税率45%;
例如,如果小明的税前工资为10000元,则A=10000-3500=6500元,其中不超过1500元部分应缴税1500×3%=45元,超过1500元不超过4500元部分应缴税(4500-1500)×10%=300元,超过4500元部分应缴税(6500-4500)×20%=400元。总共缴税745元,税后所得为9255元。
已知小明这个月税后所得为T元,请问他的税前工资S是多少元。
输入格式
输入的第一行包含一个整数T,表示小明的税后所得。所有评测数据保证小明的税前工资为一个整百的数。
输出格式
输出一个整数S,表示小明的税前工资。
样例输入
9255
样例输出
10000
评测用例规模与约定
对于所有评测用例,1 ≤ T ≤ 100000。
题解:
这题说是模拟题,其实就是像刚学选择语句时做的那种基础题
水题,不过要注意的是:S<=3500是不用交税的,而且要知道如果税前的工资大于3500,那么税后也一定是大于3500的,税前小于等于3500,税后就是这个值。
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <deque>
#include <list>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <iterator>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double E = exp(1.0);
const int MOD = 1e9+7;
const int MAX = 1e5+5;
int T;
// 给定一个钱数,求出纳税额
int GiveMoney(int s)
{
int sum = 0;
int a = s - 3500;
if(a <= 1500)
{
sum = a*0.03;
}
else if(a <= 4500)
{
sum = 1500*0.03 + (a-1500)*0.1;
}
else if(a <= 9000)
{
sum = 1500*0.03 + 3000*0.1 + (a-4500)*0.2;
}
else if(a <= 35000)
{
sum = 1500*0.03 + 3000*0.1 + 4500*0.2 + (a-9000)*0.25;
}
else if(a <= 55000)
{
sum = 1500*0.03 + 3000*0.1 + 4500*0.2 + 26000*0.25 + (a-35000)*0.3;
}
else if(a <= 80000)
{
sum = 1500*0.03 + 3000*0.1 + 4500*0.2 + 26000*0.25 + 20000*0.3 + (a-55000)*0.35;
}
else
{
sum = 1500*0.03 + 3000*0.1 + 4500*0.2 + 26000*0.25 + 20000*0.3 + 25000*0.35 + (a-80000)*0.45;
}
return sum;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while(cin >> T)
{
if(T <= 3500)
{
cout << T << endl;
}
int m = 3500;
while(1)
{
//cout << m << endl;
if(m - GiveMoney(m) == T)
{
cout << m << endl;
break;
}
m += 100;
}
}
return 0;
}