
Every guess welcome...
[cpp]#include <iostream.h>
#include <math.h>
long double n,m;
long max;
char pattern;
long get_max(long double x, long double y){
long out;
long nx,ny;
nx = int(x * 2) - 1;
ny = int(((y - 1)/sqrt(0.75))) + 1;
if(ny % 2){
out = ((ny + 1)*nx)/2;
out -= nx/2;
} else out = (nx*ny)/2;
return out;
}
int main(){
while(cin >> n >> m){
pattern = 0;
max = int(n)*int(m);
if(get_max(n,m) > max){
max = get_max(n,m);
pattern = 1;
}
if(get_max(m,n) > max){
max = get_max(m,n);
pattern = 1;
}
cout << max;
if(!pattern) cout << " grid\n";
if(pattern) cout << " skew\n";
}
return 0;
}[/cpp]