#include<iostream>
#include<cmath>
using namespace std;
int grid(float width,float height)// use string ???
{
int h=(int)height;
int w=(int)width;
return h*w;
}
int skew1(float width,float height)
{
int m1=(int)(width-0.5),n1=(int)((2*(height-1)/sqrt(3.0))+1);
int m2=(int)(height-0.5),n2=(int)((2*(width-1)/sqrt(3.0))+1);
return m1*n1>m2*n2? m1*n1:m2*n2;
}
int skew2(float width,float height)
{
int m1=(int)width,n1=(int)((2*(height-1)/sqrt(3.0))+1);
int m2=(int)height,n2=(int)((2*(width-1)/sqrt(3.0))+1);
int N1,N2;
if(n1%2==0)
N1=int(m1*n1-n1/2);
else
N1=int(m1*n1+n1/2-0.5);
if(n2%2==0)
N2=int(m2*n2-n2/2);
else
N2=int(m2*n2+n2/2-0.5);
return N1>N2? N1:N2;
}
int main()
{
float w,h;
int max=0;
while(cin>>w>>h)
{
if(grid(w,h)>skew1(w,h)){
if(grid(w,h)>=skew2(w,h))
cout<<grid(w,h)<<" grid\n";
else
cout<<skew2(w,h)<<" skew\n";
}
else
{
if(skew1(w,h)>skew2(w,h))
cout<<skew1(w,h)<<" skew\n";
else
cout<<skew2(w,h)<<" skew\n";
}
}
return 0;
}
评论