import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int t = in.nextInt(); //测试用例个数
while (--t >= 0){
int N = in.nextInt(); //行
int M = in.nextInt(); //列
if (M == 1 && N == 1) {
System.out.println(1);
continue;
}
if (N == 1){
System.out.println(M - 2);
continue;
}
if (M == 1){
System.out.println(N - 2);
continue;
}
System.out.println((long)M * N - (M << 1) - (N << 1) + 4);
}
}
}
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int t = in.nextInt(); //测试用例个数
while (--t >= 0){
int N = in.nextInt(); //行
int M = in.nextInt(); //列
if (M == 1 && N == 1) System.out.println(1);
else if (N == 1) System.out.println(M - 2);
else if (M == 1) System.out.println(N - 2);
else System.out.println((long)M * N - (M << 1) - (N << 1) + 4);
}
}
}
1
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int t = in.nextInt(); //测试用例数
while (--t >= 0) {
int n = in.nextInt(); //房子编号
int k = in.nextInt(); //用户数
if (k >= n || n <= 2 || k == 1) System.out.println(0 + " " + 0);
else if (k == n - 1) System.out.println(0 + " " + 1);
else {
int val = (n & 1);
int div = n >> 1;
if (k > (div + val)) System.out.println(0 + " " + (n - k));
else System.out.println(0 + " " + (k - 1));
}
}
}
}
通过70%