BlueBook

p171ex7: Payment

Given N (0 ≤ N ≤ 1 000 000), you are to count how many times N falls into any of the 6 ranges given below.

Range A 0 .. 9999
Range B 10000 .. 19999
Range C 20000 .. 29999
Range D 30000 .. 39999
Range E 40000 .. 49999
Range F 50000 .. 1000000

Input

Input consists of bunch of integers (0 ≤ N ≤ 1000000) which will be terminated by '-1'.
There will always be less than 10000 integers.

Output

Output the number of occurences of N in the ranges A .. F. Output '0' if N was never found for that particular range.
Do not include -1 into your calculations.

Sample Input

1
9999
10001
1000000
29999
-1

Sample Output

2
1
1
0
0
1

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 26, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

What does it mean to output the number of times N is in a range?

Like the number 1, isn't it ONLY in Range A once? And doesn't appear in any other range? Why would the output be 2?

You are to output exactly 6 integers, no matter how many integers are in the input.

In the sample case, there are two integers in Range A: 1 and 9999.

I'm confused, what is the program supposed to do?

You're supposed to make a program that counts the amount of times a number that you input is in a certain range, The first output is the amount of times a number falls into the range of 'A', second output tells you 'B' and so on and so forth.

he asked what's wrong not what to use

Oh my god param, you proved me wrong!!! Good job!!

is that necessary..? and still doesnt work..?!?!

Jay, try using 'longint' for the input. An 'Integer' can only go up to 32767 or go down upto -32768.