hihocoder 1102 Individual Income Tax

#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


//沒啥說的,超笨的方法

#include "iostream"
using namespace std;

int a[7],b[7];
double c[8];

int main(){

    a[0] = 0;       b[0] = 0;        c[0] = 0.00;
    a[1] = 45;      b[1] = 1500;     c[1] = 0.03;
    a[2] = 300;     b[2] = 4500;     c[2] = 0.10;
    a[3] = 900;     b[3] = 9000;     c[3] = 0.20;
    a[4] = 6500;    b[4] = 35000;    c[4] = 0.25;
    a[5] = 6000;    b[5] = 55000;    c[5] = 0.30;
    a[6] = 8750;    b[6] = 80000;    c[6] = 0.35; c[7] = 0.45;

    for(int i = 1; i <= 6; i++) a[i] = a[i]+a[i-1];

    int m,k;
    while(cin >> m){
    for(int i = 6; i >= 0;i--) {
        if(m >= a[i]) {
            k = i;
            break;
        }
    }
    cout <<(int)( b[k] + (m- a[k])/c[k+1] + 3500) << endl;

    }
  return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章