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)
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?
In the sample case, there are two integers in Range A: 1 and 9999.