The world was booming...war and destruction everywhere. It all started out a couple of years ago. The world was at its economic bottom...there was little hope left. Most of the resources our nation had have been used up, and with the little money we had left the government was trying to produce as many synthetic supplements as possible to keep the population from starving. Russia's power was growing. After an alliance with the Chinese government, they practically ruled the eastern hemisphere. Our own government was falling apart. Most of the departments were on lock down, and the president was starting to lose all of his credibility. I have been called in as a backup. Despite my choice to become a soldier I am also a programmer. Since most of the programming staff had either been kidnapped or killed by the Russian military, we needed as much help as we could get. Threats. Early this morning we received a call from one of the Chinese officials...apparently no amount of gold could possibly repay our debts to them... so it was either surrender or pay up! I strolled past one of the officers straight towards the huge, bolted titanium doors which lead to the National Economic Data department. As soon as I entered, the smell of sweat and panic filled my lungs. We were gathering our last efforts and checking all of our accounts when the PA system start turned on.
Get ready for another one the vice-president barked damn Chinese... ain't no amount of cash that can satisfy those greedy sons of...his voice was cut off.
I turned one of the laptops and was surprised to find another tax table. I remember when my parents first found out about these...it was devastating... the government confiscated almost everything we had...now they were living in shelters...like the rest of the nation's population.
Tax rate | Single | Married joint filers Surviving spouses | Heads of household | Married filing separately |
---|---|---|---|---|
10% | $9,075 or less | $18,150 or less | $12,950 or less | $9,075 or less |
15% | $9,075-$36,900 | $18,150-$73,800 | $12,950-$49,400 | $9,075-$36,900 |
25% | $36,900-$89,350 | $73,800-$148,850 | $49,400-$127,550 | $36,900-$74,425 |
28% | $89,350-$186,350 | $148,850-$226,850 | $127,550-$206,600 | $74,425-$113,425 |
33% | $186,350-$405,100 | $226,850-$405,100 | $206,600-$405,100 | $113,425-$202,550 |
35% | $405,100-$406,750 | $405,100-$457,600 | $405,100-$432,200 | $202,550-$228,800 |
39.6% | $406,750 or more | $457,600 or more | $432,200 or more | $228,800 or more |
The tax formula is taxable_incomeâ
tax_rate
. Find the tax for a given person.
Input
The first line of the input is the type of filer, one ofSingle
, Married joint filer
, Surviving spouse
, Head of household
, Married filing separately
(case-sensitive).The second line of the input is the taxable income, in dollars.
Output
Print the tax, rounded down.Constraints
The taxable income is at least $1 and at most $500,000.The taxable income is NOT divisible by 5.
Sample
Input | Output | Explanation |
---|---|---|
Single 1237 | 123 | The tax is $1237 * 10% = $123.7 , which is 123 (rounded down). |
Married filing separately 70001 | 17500 | The tax is $70001 * 25% = $17500.25 , which is 17500 (rounded down). |
Surviving spouse 472513 | 187115 |
1 #!/usr/bin/perl -w 2 use v5.14; 3 4 my @taxes = (10, 15, 25, 28, 33, 35, 39.6); 5 6 my %types; # Hash de la tipuri de persoane la punctele unde se schimba taxa 7 # Daca valoarea e mai mica decat $types{$type}[$i], taxa e $taxes[$i] / 100. 8 $types{Single} = [9075, 36900, 89350, 186350, 405100, 406750, 500000]; 9 $types{'Married joint filer'} = [18150, 73800, 148850, 226850, 405100, 457600, 500000]; 10 $types{'Head of household'} = [12950, 49400, 127550, 206600, 405100, 432200, 500000]; 11 $types{'Married filing separately'} = [9075, 36900, 74425, 113425, 202550, 228800, 500000]; 12 $types{'Surviving spouse'} = $types{'Married joint filer'}; 13 14 my ($type, $amount) = <>; # Citim tipul de persoana si valoarea taxabila 15 chomp $type; # Stergem newline-ul din $type 16 17 for my $i (0 .. $#taxes) { # Luam pe rand tax bracket-urile 18 if ($types{$type}[$i] > $amount) { # Daca valoarea se incadreaza in acest bracket... 19 say int ($amount * $taxes[$i] / 100); # ... scriem raspunsul 20 exit # ... si ne oprim 21 } 22 }