Batman and Joker!
All submissions for this problem are available.Arkham Prison has had a mass breakdown caused by Joker who has some guns to pass out to the inmates. The joker decides the fairest way to divide the guns is to seat the inmates around a circular table in chairs numbered by a sequence. A chair number will be drawn from a bag. Beginning with the inmate in that seat, one gun will be handed to each person sequentially around the table until all guns have been distributed. The Joker likes playing tricks on the inmates. One last piece of artillery looks similar to all the others, but it backfires on the shooter. Batman is watching the scene and has to determine the seat number occupied by the person who will receive that defective piece. Eg: There are 4 prisoners seated on chairs 1 through 4, and 6 pieces of guns. The number picked from the bag is two. Prisoners receive guns in the order 2, 3, 4, 1, 2, 3. The inmate that has to be saved by Batman is number 3. ### Input Format The first line contains an integer, $t$, denoting the number of test cases. The next $t$ lines each contain $3$ space-separated integers: $n$: the number of inmates $m$: the number of guns $s$: the number that is picked from the bag. ### Output Format For each test case, print the number of the seat of the inmate who receives the defective gun on a new line ### Constrainst $1<=t<=100$ $1<=n<=10^9$ $1<=m<=10^9$ $1<=s<=n$ ### Sample Input ``` 2 5 2 1 5 2 2 ``` ### Sample Output ``` 2 3 ```
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions