Problem 5Problem code: CME05 |
All submissions for this problem are available.
Ravi Sharma is a geek ,pursuing his B-Tech in one of the prestigious institutes of India. His birthday falls on 18th of December. This time on his birthday he decided to take all his 14 friends to watch Avatar , the most expensive movie ever released on the silver screen. So he along with his friends went to a nearby popular theatre but were shocked to see a very long queue on the Ticket Window. Even then Ravi joined the queue with hope of getting at least 3 tickets-one definitely for himself, another one for his girlfriend and remaining one for his best friend Sunny. And as said- Fortune favours the brave. He returned with three tickets. But now, all his friends wanted to see the movie with him and selecting some favorites out of them was always going to spoil the party. On the back of Ravi s mind ,it was there to take his girlfriend and Sunny to the movie but he was in a situation in which he could not express his feelings in front of his friends. So Ravi took out the solution to the problem by solving a Combinatorial problem in his mind. He told that all his friends will be playing a game the two winners of which will be accompanying him to the movie. He told all his friends (including his girlfriend and friend Sunny) to stand in a circular manner and declared that every third person will get out until only two of them remained . This problem asks you to determine which J positions out of a circle of M should be chosen so that the J people will always remain ,if every kth person is out. Write on one line the positions which should be chosen for J people to be the winners in order that they would be chosen for termination should the activity have continued.
Input
The first line contains the number of test cases. The following lines contain the data. The data will consist of triples (M,K,J positive integers such that M>J)
Output
For example: a)In the case given ,which position should his girlfriend and his friend Sunny should take if they are the last 2 persons remaining out of 14 persons if every third person gets out. 2)If the input is 10,2,5 which positions should be taken if 5 persons are to remain and every 2nd person is out?
Example
Input: 1 41 3 2 Output: 16 31
| Author: | vishesh_sigma |
| Date Added: | 28-01-2010 |
| Time Limit: | 50 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

@Admin could you please
@Admin could you please specify how large m can be?
now m completely frustrated
now m completely frustrated ....
1. Limits ... check
2. Displaying them termination order ... check?.
3. Various output formats (the extra space after each case) ... check.
Anyone else on it beside me ?
@admin.......... sir my code
@admin..........
sir my code is running on machine well.............. and i sure that my code is fine but sir i'm getting runtime error so sir please check the test cases once because nobody successfully submitted this problem. please varify..
i think the order of the m,j,k is not proper..
thanx..
@admin i'm waiting for ur
@admin
i'm waiting for ur response.............
same here .. the seems to be
same here .. the seems to be some drastic problem. The code runs fine on my machine but not on the server.
even I got runtime error with SIGSEGV.
works on my system.but it