Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Harmony Forever
Description We believe that every inhabitant of this universe eventually will find a way to live together in harmony and peace; that trust, patience, kindness and loyalty will exist between every living being of this earth; people will find a way to appreciate and cooperate with each other instead of continuous bickering, arguing and fighting. Harmony — the stage of society so many people dream of and yet it seems so far away from now… Fortunately, the method of unlocking the key to true Harmony is just discovered by a group of philosophers. It is recorded on a strange meteorite which has just hit the earth. You need to decipher the true meaning behind those seemingly random symbols… More precisely, you are to write a program which will support the following two kinds of operation on an initially empty set *B X*: Add number*X*to set*S*. The*K*^{th}command in the form of*B X*always happens at time*K*, and number*X*does not belong to set*S*before this operation.*A Y*: Of all the numbers in set*S*currently, find the one which has the minimum remainder when divided by*Y*. In case a tie occurs, you should choose the one which appeared latest in the input. Report the time when this element is inserted.
It is said that if the answer can be given in the minimum possible time, true Harmony can be achieved by human races. You task is to write a program to help us. Input There are multiple test cases in the input file. Each test case starts with one integer
Output Print the result of each test case in the format as indicated in the sample output. For every line in the form of “ Sample Input 5 B 1 A 5 B 10 A 5 A 40 2 B 1 A 2 0 Sample Output Case 1: 1 2 1 Case 2: 1 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator