输入的第一行包含一个整数
,表示询问的数量。
接下来
行,第
行包含两个整数
——本次询问的参数。
对于每个询问,输出一行一个整数,表示答案。
4 2 3 5 17 8 2 4 4
1 2 2 4
以第一组询问
为例:
订单编号序列为
,第
个编号为
,故输出
。
其余询问均可按相同规则得到答案。
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int q = in.nextInt(); while (q-- != 0) { int m = in.nextInt(), x = in.nextInt(); System.out.println((x - 1) % m + 1); } } }