搜索+优化….
貌似没什么好说的(逃
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=302; const LL inf=1ll<<60;
inline int read(){
char ch=getchar(); int x=0,f=1;
while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0'; ch=getchar();}
return x*f;
}
int n,m,k; LL f[N][N][2][2][2][2];
LL dfs(int x,int y,int a,int b,int c,int d){
if(x>y) x^=y^=x^=y,a^=c^=a^=c,b^=d^=b^=d;
if(a>b) a^=b^=a^=b;
if(c>d) c^=d^=c^=d;
if(f[x][y][a][b][c][d]<inf)return f[x][y][a][b][c][d];
LL u=(LL)(x*y-k)*(LL)(x*y-k); int i;
if(a || b || (c&&d))
for(i=1;i<x;++i) u=min(u,dfs(i,y,a,b,0,d)+dfs(x-i,y,a,b,c,0));
if(c || d || (a&&b))
for(i=1;i<y;++i) u=min(u,dfs(x,i,a,0,c,d)+dfs(x,y-i,0,b,c,d));
return f[x][y][a][b][c][d]=u;
}
int main()
{
n=read(),m=read(),k=read();
for(int i=1;i<N;++i)for(int j=1;j<N;++j)
for(int a=0;a<2;++a)for(int b=0;b<2;++b)
for(int c=0;c<2;++c)for(int d=0;d<2;++d)
f[i][j][a][b][c][d]=inf;
printf("%lld\n",dfs(n,m,1,1,1,1));
return 0;
}