BlueBook
p108ex7 - Cost
Given an integer N (0 ≤ N ≤ 100,000) representing the mass of a letter in grams, print out the cost in cents to mail the letter.
The first line of input will be the number of test cases T (1 ≤ T ≤ 100). The following T lines will contain N. Output the cost in cents to mail the letter.
The pricing is as follows :
0 ≤ N ≤ 30 costs 38 cents
30 < N ≤ 50 costs 55 cents
50 < N ≤ 100 costs 73 cents
if N > 100 then the base cost is 73 cents, plus 24 cents for every additional 50 grams or part thereof.
Input
The first line of input will be the number of test cases T (1 ≤ T ≤ 100). The following T lines will contain N.
Output
Output the cost in cents to mail the letter.
Sample Input
2
5
101
Sample Output
38
97
All Submissions
Best Solutions
Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 21, 2008
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
Write out some test cases for yourself -- make up some possible inputs, then try to figure out what the output should be for that. Then, run your program with those inputs.
50 grams or part thereof - 150 is 50 grams exactly. As such, only one additional charge is incurred... don't blindly trust your program; if you're asked a question intended to provoke thought as to why you got something wrong, it would make sense to pay it some attention...
"Part thereof" means a part of the thing just mentioned. So even if the thing weighs just one gram extra, it is still charged as a full fifty grams.
there should be a simple formula for it...consisting of only two lines...its just the formula ur doing is wrong. think more of it...like instead of subtracting 100, something a BIT bigger...
I am writing this because my program works for the test cases but none of them are right when I submit.
Why do you add 24? Should you not be adding 73??