tag:模擬
#include <cstring>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define maxn 100010
int b[7];
struct Cube
{
int a[7];
void right()
{
memcpy(b,a,sizeof(a));
a[1]=b[1];
a[5]=b[5];
a[2]=b[4];
a[3]=b[2];
a[4]=b[6];
a[6]=b[3];
}
void left()
{
memcpy(b,a,sizeof(a));
a[1]=b[1];
a[5]=b[5];
a[2]=b[3];
a[6]=b[4];
a[4]=b[2];
a[3]=b[6];
}
void down()
{
memcpy(b,a,sizeof(a));
a[3]=b[3];
a[4]=b[4];
a[1]=b[2];
a[2]=b[5];
a[5]=b[6];
a[6]=b[1];
}
long long get()
{
return a[2];
}
long long row()
{
return a[2]+a[4]+a[6]+a[3];
}
void Print()
{
cout<<a[2]<<":"<<a[4]<<":"<<a[6]<<":"<<a[3]<<endl;
cout<<endl;
}
}cube;
int main()
{
int r,c;
while(scanf("%d%d",&r,&c)!=EOF)
{
cube.a[6]=6;
cube.a[2]=1;
cube.a[3]=3;
cube.a[4]=4;
cube.a[5]=5;
cube.a[1]=2;
long long ans=1;
int tmp=(c-1)%4;
bool ok=1;
for(int i=1;i<=r;i++)
{
//cout<<i<<":"<<ans<<endl;
ans+=(c-1)/4*cube.row();
if(ok)
{
for(int j=1;j<=tmp;j++)
{
cube.right();
//cout<<cube.get()<<endl;
ans+=cube.get();
}
ok=0;
}
else
{
for(int j=1;j<=tmp;j++)
{
cube.left();
//cout<<cube.get()<<endl;
ans+=cube.get();
}
ok=1;
}
if(i==r)
break;
cube.down();
ans+=cube.get();
}
printf("%I64d\n",ans);
}
return 0;
}