C-PROM 2014 (PROBLEM 10 :DECODING ROMAN NUMERALS)

C-PROM 2014 (PROBLEM 10 :DECODING ROMAN NUMERALS)



PROBLEM 10 : DECODING ROMAN NUMERALS


The roman people uses the Roman Numerals for base 10 numbers. Each numeral-character such as I, V, X, L, C, D and M has a single value such as 1, 5, 10, 50, 100, 500 and 1000 respectively. The value of Roman Numerals is the sum of its numeral-characters unless a smaller numeral-character is placed in front of larger numeral-character, in which case the smaller numeral-character is subtracted from the total. For instance VI = 5 + 1, while IV = 5 – 1. You may assume that at most one subtraction is required per number.

Input
Input are in the form of text string for roman numerals, separated by a single space in a single line.

Output
For each roman numerals, print the number in base 10 numbers at a single line.


Sample Input
Sample Output
IV LXI CLV DI MDCLXVII
4
61
155
501
1667



Problem Setter : Jamal Othman, UiTM Pulau Pinang




C-PROM 2014 (PROBLEM 9 :PALINDROME)

C-PROM 2014 (PROBLEM 9 :PALINDROME)



PROBLEM 9 : PALINDROME


A positive integer is said to be a palindrome with respect to base b, if its representation in base b reads the same from left to right as from right to left. Palindromes are formed as follows:
Given a number, reverse its digits and add the resulting number to the original number. If the result isn't a palindrome, repeat the process. For example, start with 87 base 10. Applying this process, we obtain:
87 + 78 = 165
165 + 561 = 726
726 + 627 = 1353
1353 + 3531 = 4884, a palindrome

Whether all numbers eventually become palindromes under this process is unproved, but all base 10 numbers less than 10,000 have been tested. Every one becomes a palindrome in a relatively small number of steps (of the 900 3-digit numbers, 90 are palindromes to start with and 735 of the remainder take fewer than 5 reversals and additions to yield a palindrome). Except, that is, for 196. Although no proof exists that it will not produce a palindrome, this number has been carried through to produce a 2 million-digit number without producing a palindrome.

Input
The first line of the input contains an integer N (1 ≤ N ≤ 5), the number of test cases. Following the first line are the test cases. Each line of a test case contains an integer number. All test cases are non negative integer numbers.
The input must be read from standard input.

Output
Print the palindrome number produced and followed by for how many attempts the palindrome number is found. If no palindrome is produced after 10 attempts, print the last sum and the word “none”.

Sample Input
Sample Output
5
87
196
1689
46785
46894

4884;Palindrome;5
10755470;None
56265;Palindrome;5
1552551;Palindrome;4
664272356;None




Problem Setter : Jamal Othman, UiTM Pulau Pinang


C-PROM 2014 (PROBLEM 8 :COMPUTE COOKIES SOLD)

C-PROM 2014 (PROBLEM 8 :COMPUTE COOKIES SOLD)



PROBLEM 8 : COMPUTE COOKIES SOLD


Students at a local middle school volunteered  to sell fresh baked cookies to raise funds to increase the number of computers for the computer lab. Each student reported the number of boxes he/she sold.

Input

The first line of the input contains an integer N (1 ≤ N ≤ 5), the number of volunteers. Following the first lines are the test cases which are; the name of each volunteer with the number of boxes that he/she had sold.  The final line indicates the unit price for a box of cookies.

Output

The report of the result will be the total number of boxes of cookies sold, the unit price of the box, the total revenue generated by selling the cookies, and the average number of boxes sold by each student.

Sample Input
Sample Output
5
Sara 120
Lisa 128
Cindy 359
Nicole 267
Blair 165
3.5
1039
3.50
3636.50
207



Problem Setter : Umi Hanim Mazlan





C-PROM 2014 (PROBLEM 7 :TIME CLOCK)

C-PROM 2014 (PROBLEM 7 :TIME CLOCK)



PROBLEM 7 : TIME CLOCK


You need to compute the total time a worker has worked on a single calendar day given two timestamps of the form “HH:MM”. The numbers MM can be in the range of “00” to “59” while HH is in the range “01” through “12”. This is an archaic (old-fashioned) timestamp clock that doesn’t even record AM or PM values. The system has worked well in the past because no-one has ever worked longer than an 8 hour shift.

You can be assured that the two times are different and represent an employee checking in to work (on a calendar day) and checking out from work later on the exact same calendar day. You are to output the total time as “HH:MM”. If the accumulated work time is greater than 8 hours (in other words, 481 minutes or longer), then you are ordered to output “08:00” because this is the maximum time that the employee would be paid.

Input
The first line of the input contains an integer N (1 ≤ N ≤ 30), the number of test cases. The following line will contain pairs of timestamps representing the starting and ending time containing five characters of the form “HH:MM” where HH is in the range “01” and “12” while MM in the range “00” through “59”.

The input must be read from standard input.


Output
The output of the program should display the accumulated time as “HH:MM” on a single line by itself where HH represents the number of hours in the range “00” to “12” and MM represents the number of minutes in the range “00” and “59”.

The output must be written to standard output.


Sample Input
Sample Output
4
09:13 04:42
09:12 10:03
03:10 11:15
07:13 01:01


07:29
00:51
08:00
05:48



Problem Setter : Mohd Nizam Osman