Result: Accepted
Time: 8ms
Memory: 1120kB
#include <stdio.h>
int size(int x,int y,int z,int s) {
int output;
output = z * (x - 2 * s) * (y - 2 * s);
return output;
}
int main ()
{
int a,b,c,d,e;
int all;
int result;
int u;
while(scanf("%d %d %d %d %d",&a,&b,&c,&d,&e) != EOF)
{
all = a * b * c;
if (d < e)
{
result = all - 2 * size(a,c,d,e) - 2 * size(b,c,d,e) - 2 * size(a,b,d,e);
printf("%d\n",result);
result = 0;
}
else if (2 * d >= a || 2 * d >= c || 2 * d >= b)
{
result = all - 2 * size(a,c,e,e) - 2 * size(b,c,e,e) - 2 * size(a,b,e,e) - (a - 2 * e) * (b - 2 * e) * (c - 2 * e);
printf("%d\n",result);
result = 0;
}
else
{
result = all - 2 * size(a,c,e,e) - 2 * size(b,c,e,e) - 2 * size(a,b,e,e) - (a - 2 * e) * (b - 2 * e) * (c - 2 * e);
u = (a - 2 * d) * (b - 2 * d) * (c - 2 * d);
if (result < u) {
printf("%d\n",u);
} else {
printf("%d\n",result);
}
}
}
return 0;
}