题意和题目https://blog.csdn.net/A852852852852/article/details/47703729
#include <iostream>
#include <math.h>
using namespace std;
int skew(double a,double b)
{
if(a-(int)a<0.5)
{
int h;
h=(b-1)*2/sqrt(3);
h=h+(b>=1);
return h*(int)a-((int)h/2);
}
else
{
int h;
h=(b-1)*2/sqrt(3);
h=h+(b>=1);//之前忘记考虑只有一行的情况,WA了三发
return h*(int)a;
}
}
int main()
{
double a,b;
while(cin>>a>>b)
{
if(a<1&&b<1)
{cout<<"0 grid"<<endl;//特判
}
else{
int g=(int)a*(int)b;
int s1,s2,s;
s1=skew(a,b);//错位堆叠需要考虑两种情况,底和高互换
s2=skew(b,a);
s=max(s1,s2);
if(g>=s)
cout<<g<<' '<<"grid"<<endl;
else
cout<<s<<' '<<"skew"<<endl;
}
}
return 0;
}