题解 | #翻转翻转#

翻转翻转

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);
        }

    }
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 17:10
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务