UVa 12342 tax Calculator (water problem, taxes)

Source: Internet
Author: User

See a water problem at UVA today and share it.

Test instructions: The total amount of tax, there are several requirements, if the first 180000, not satisfied, the next 300000, Na 10%, then a 400000, Na 15%, another 300000, Na 20%, after the Na 25%, if the total is greater than 0 but but 2000, NA 2000,

If the total amount is not an integer, NA is the nearest and larger integer than it.

Analysis: There is nothing to say, count on the line, there is no pit.

The code is as follows:

#include <bits/stdc++.h>using namespace Std;const int s[] = {1180000, 880000, 480000, 180000};const double tax[] = { 0.25, 0.2, 0.15, 0.10};int main () {    int T, n;  Cin >> T;    for (int kase = 1; kase <= T; ++kase) {        double ans =0;        scanf ("%d", &n);        for (int i = 0; i < 4; ++i)            if (n > s[i]) {                ans + = (n-s[i]) * Tax[i];                n = s[i];            }        printf ("Case%d:%d\n", kase, ans = = 0? 0:max (+, (int) ceil (ans)));    }    return 0;}

UVa 12342 tax Calculator (water problem, taxes)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.