题解 | #翻转翻转#
翻转翻转
http://www.nowcoder.com/practice/ad11db28e0f44a1c97af06fd002477a1
import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int num = sc.nextInt(); for(int i = 1; i <= num; i++){ long n = sc.nextLong(); long m = sc.nextLong(); long s ; if(n == 1 && m == 1){ s = 1; }else if(n == 1){ s = m - 2; }else if(m == 1){ s = n - 2; }else{ s = (n - 2) * (m - 2); } System.out.println(s); } } }