码迷,mamicode.com
首页 > 其他好文 > 详细

hihoCoder - 1102 - Individual Income Tax (数学~)

时间:2015-02-07 09:10:52      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:acm   hihocoder   数学   

#1102 : Individual Income Tax

时间限制:10000ms
单点时限:1000ms
内存限制:256MB

描述

For incomes from wages and salaries, the progressive tax rate in excess of specific amount is applicable. The income amount taxable shall be the remainder after deducting 3500 yuan from the monthly income. The tax rate is below:

Grade Monthly Taxable Income
Tax Rate(%)
Income of 1,500 yuan or less
3%
That part of income in excess of 1,500 to 4,500 yuan
10%
That part of income in excess of 4,500 to 9,000 yuan
20%
That part of income in excess of 9,000 to 35,000 yuan
25%
That part of income in excess of 35,000 to 55,000 yuan
30%
That part of income in excess of 55,000 to 80,000 yuan
35%
That part of income in excess of 80,000 yuan
45%

Given the tax Little Hi paid, do you know his salary this month?

输入

Line 1: M, the tax Little Hi paid. (1 <= M <= 5,000,000)

输出

Line 1: Little Hi‘s salary. The number should be rounded dowm to the nearest integer.

提示

Little Hi‘s salary is 15692 yuan. The tax is calculated below:
The income amount taxable is 15692 - 3500 = 12192 yuan.
That part of income of 1500 or less: 1500 * 3% = 45 yuan.
That part of income in excess of 1,500 to 4,500 yuan: 3000 * 10% = 300 yuan.
That part of income in excess of 4,500 to 9,000 yuan: 4500 * 20% = 900 yuan.
That part of income in excess of 9,000 to 35,000 yuan: (12192 - 9000) * 25% = 798 yuan.
Total tax is 45 + 300 + 900 + 798 = 2043 yuan.

样例输入
2043
样例输出
15692


根据你的税算出你的收入。。


AC代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	double rate[10] = {0.03, 0.1, 0.2, 0.25, 0.3, 0.35, 0.45};
	double b[10] = {0, 1500, 4500, 9000, 35000, 55000, 80000};
	double a[10] = {0, 45, 300, 900, 6500, 6000, 8750};
	for(int i=1; i<=6; i++) {
		a[i] += a[i-1];
	}
	
	double m, ans;
	while(scanf("%lf", &m) != EOF) {
		for(int i = 6; i>=0; i--) {
			if(m > a[i]) {
				ans = b[i] + (m - a[i]) / rate[i];
				break;
			}
		}
		printf("%d\n", (int)(ans + 0.1) + 3500);
	}
	return 0;
}











hihoCoder - 1102 - Individual Income Tax (数学~)

标签:acm   hihocoder   数学   

原文地址:http://blog.csdn.net/u014355480/article/details/43578745

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!