Can You Help Misty
All submissions for this problem are available.
Four Friends residing in the New York plan to watch a play at a theatre. They book their tickets on Friday for a show on Sunday. They did confirm their arrival by calling at the theatre office on Saturday and they were assured their booking. On Sunday morning, when the smartly dressed gents with their beautiful ladies reached at theatre they uttered a cry. To their shock and disbelief a crowd of too many people had gathered. The play was such a big hit that every family decided to watch it live on that day, because the day was Sunday. But these gents and ladies had booked tickets. They went to the gate directly but were shooed away from the gate by the mobbing crowd like pigeons. They asked an elder guy, Gandpa standing beside them, ‘how could we manage our entry in there?’. The guy had a hearty laugh at them and told them it was impossible. Hearing this, little misty started crying. Jewonson, her husband and the other couple thereby agreed to get misty watch the play anyhow and by any means.
Assume Jewonson is a computer programmer and his friend Pills is an analyst. Both just get set to work. Pills goes all-around the place and figures out that the entry to the play is on the basis of ‘Enki Pinkie’. i.e.
All people present formed a circle, a startingplace was chosen, and Gandpa went around counting out
`E', `n', `k', `i', `P', `i',`n', `k', `i', `e',`i', `P', `o', `n', `k', `i', `e', `E', `n', `k',`i', `e', `g', `o', `t', `O', `u', `t', `H', `A!', \0 .
At `A!', the person was removed from the circle which was then shrunken and the enki pinkie began again with the person next to him . This process continued until only one wasleft---the allowed play viewer.
Pills also tells misty’s husband that the crowd consists of at-max 500 people. But he wasn’t sure how many were taking part in the selection method and how many were a part of a useless mob. Also he couldn’t find in which direction the count would begin (clockwise or anti-clockwise). But Pills, being a great analyst somehow managed to get to know that when Jewonson’s wife would be in the selection process, the count would start from hirgda. He also found out that gandpa would be excluded from the count. So misty’s husband’s job was to find where should misty stand (closest to hirgda) and doesn’t get out.
Now the job of analyst’s friend and of-course misty’s husband is to write a program to find the first and the nearest position for misty to stand taking care of what the analyst could not find.
The input to jewonson’s code would be of many lines. Each line specifying lower and upper bounds of the number of people who want to be in the selection process. First upper bound is given followed by a space and then lower bound is provided. Both the bounds are inclusive in the selection process.
To stop the input the last line will contain two zeros. (0 0)
For each input line, there will be corresponding output. Each line of the output would the position closest to hirgda that would not be chosen as a position where the enki pinkie tale terminates (i.e. where ‘A!’ doesn’t come.)
If no such position is available,
Output the string : “No Such Position available!”
60 90 45 155 0 0
1 No Such Position available!
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, D, PERL, FORT, ADA, ASM, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, TCL, PERL6, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.