题解 | 选数
选数
https://www.nowcoder.com/practice/9e938a706419422d9baf0132a7413b4d
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int T = scanner.nextInt();
while (T-- > 0) {
long n = scanner.nextLong();
long k = scanner.nextLong();
long groups = Math.min(k, n - k + 1);
System.out.println(groups);
}
}
}


查看9道真题和解析