#Lutece0525. 猴子选大王
猴子选大王
Migrated from Lutece 525 猴子选大王
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
有个猴子围成一圈,按顺时针编号,分别为到。现打算从中选出一个大王。经过协商,决定选大王的规则如下:从第一个开始顺时针报数,报到的猴子出圈,紧接着从下一个又从顺时针循环报数,...,如此下去,最后剩下来的就是大王。
Input
第一行是一个正整数表示测试数据的组数。下面共有行,每行两个整数和,用一个空格隔开,分别表示猴子的个数和报数。,。
Output
每组数据对应有一个输出,表示大王的编号。
Samples
1
3 2
3
Resources
wxiaoping 2009年C语言第六次上机