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)