11
17
2015
0

BZOJ4312-立方体

好恶心好恶心好污好污的分类讨论!

frown具体就看代码吧 没什么好讲的 注意一(ju)点(duo)细节就行了

#include <cstdio>
#define ll long long
ll x,y,z;
ll ans(ll x,ll y,ll z)
{
	if (y==1)
		return 0;
	if (x==1)
		return (y==2)?((z==2)?0:(z-3)):(y+z-((y&z&1)?4:5));
	if (x==2)
		return (y-2)*(z-2)+3;
	if (x==3)
		return (y==3)?((z<<1)+((z&1)?6:4)):((y-1)*(z-1)+((y&1)?((z&1)?8:6):((z&1)?6:5)));
	return (x-2)*(y-2)+(x-2)*(z-2)+(y-2)*(z-2)+9;
}
int main()
{
	int TT=0;
	while (scanf("%lld%lld%lld",&x,&y,&z)!=EOF)
	{
		if (x>y) {ll t=x;x=y;y=t;}
		if (x>z) {ll t=x;x=z;z=t;}
		if (y>z) {ll t=y;y=z;z=t;}
		printf("Case #%d: %lld\n",++TT,x*y*(z-1)+x*(y-1)*z+(x-1)*y*z+ans(x,y,z));
	}
	return 0;
}

 

Category: 未分类 | Tags: | Read Count: 542

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com