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)

<
1
2
>

What is wrong with my code? It works for all my test cases and its always a 7/11.

my code will only garner a 1/11. How should I improve it?

first, please read the question carefully next time, there are multiple cases, the first integer tells u how many cases in total, and the cases will follow. your program can only take one case, it should be able to take multiple

I don't know what I'm doing wrong

Being able to figure out what you're doing wrong is a more important skill than being able to figure out a solution in the first place.

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.


What should the extra charge be if a letter is exactly 50 grams more than the limit?

I don't know

if N > 100 then the base cost is 73 cents, plus 24 cents for every additional 50 grams or part thereof.

121

Why 121?
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...


what does part thereof mean?

didnt brian just answer this question with one of your other posts?

nvm

Tip: You can edit your own comments.
"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.

xactly gaby how would you not now that?

so mean

gaby ur code for cost the else if n>100 thing is too long
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...

Why am i getting it wrong can someone check :S

First rewrite your program so that it processes test cases one at a time, instead of reading in the entire input and then printing the entire output all in one shot.

Does it want us to add the outputs and are there negative inputs.

I am writing this because my program works for the test cases but none of them are right when I submit.

n2 := (24 * d) + 24;

Why do you add 24? Should you not be adding 73??

Your method of calculating is simply wrong.

everything? or only the above 100 part?