hiho week 74 register

Ended

Participants:174

Verdict:Accepted
Score:100 / 100
Submitted:2015-11-28 21:45:37

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<cstdio>
int incom[7] = { 1500, 4500, 9000, 35000, 55000, 80000, 1e9 };
int tax_accum[7] = { 45, 345, 1245, 7745, 13745, 22495, 1e9 };
double rate[7] = { 0.03, 0.1, 0.2, 0.25, 0.3, 0.35, 0.45 };
int main() {
    double m, ans;
    scanf("%lf", &m);
    int lvl = -1;
    for(int i = 0; i < 7; ++i) if (m <= tax_accum[i]) { lvl = i; break; }
    if (lvl == 0) { ans = m / 0.03; }
    else {
        double a = m - tax_accum[lvl - 1];
        double b = a / rate[lvl];
        ans = incom[lvl - 1] + b;
    }
    printf("%d\n", int(ans += 3500));
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX