尚有不足,请高手勿喷,有高见请不吝赐教
import java.util.Scanner;
public class T3 {
/*一条街上n个房子,k个住户
* 你需要找一个房子两边都有邻居
* 要求得到所有可能性中,
* 最小符合的房子数和最大符合的房子数
* 输入
* t行,n,k
* 输出最小符合的房子数和最大符合的房子数
*
*
* 示例
* 6
* 1 0
* 1 1
* 2 0
* 2 1
* 2 2
* 6 4
*
* 输出
* 0 0
* 0 0
* 0 0
* 0 0
* 0 0
* 0 2
*
*
* */
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=0;
t=sc.nextInt();
int[][] re=new int[t][2];
for (int i = 0; i < t; i++) {
int n=0,k=0;
n=sc.nextInt();
k=sc.nextInt();
if(k>=n-1||n<3||k<2) {
re[i][0]=0;
re[i][1]=0;
}else if(n-k>=2) {
re[i][0]=0;
re[i][1]=n-k;
}
}
for (int i = 0; i < re.length; i++) {
System.out.print(re[i][0]+" "+re[i][1]+"\n");
}
}
}