二货小易有一个W*H的网格盒子,网格的行编号为0~H-1,网格的列编号为0~W-1。每个格子至多可以放一块蛋糕,任意两块蛋糕的欧几里得距离不能等于2。 对于两个格子坐标(x1,y1),(x2,y2)的欧几里得距离为: ( (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2) ) 的算术平方根 小易想知道最多可以放多少块蛋糕在网格盒子里。

import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner scanner=new Scanner(System.in);
int W=0;
int H=0;
W = scanner.nextInt();
H = scanner.nextInt();
if(W%4==0||H%4==0){
System.out.println(W*H/2);
}else{
if(W%2==0||H%2==0){
System.out.println(W*H/2+1);
}else{
System.out.println(W*H/2+1);
}
}
}

}

posted @ 2018-04-02 16:13  Syiren  阅读(250)  评论(0编辑  收藏  举报