| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
2977,枚举还是不过#include<iostream>
using namespace std;
int main()
{
__int64 lx,ly,lz,x,y,z;
while(scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&lx,&ly,&lz,&x,&y,&z)&&(lx||ly||lz||x||y||z))
{
__int64 min=9999999999;
if(z==0&&x<lx&&y<ly)
min=x*x+y*y;
else
if(x==0&&y<ly&&z<lz)
min=y*y+z*z;
else
if(y==0&&x<lx&&z<lz)
min=x*x+z*z;
else
if(x==lx&&y<ly&&z<lz)
min=((x+y)*(x+y)+z*z)<((x+z)*(x+z)+y*y)?((x+y)*(x+y)+z*z):((x+z)*(x+z)+y*y);
else
if(y==ly&&x<lx&&z<lz)
min=((x+y)*(x+y)+z*z)<((y+z)*(y+z)+x*x)?((x+y)*(x+y)+z*z):((y+z)*(y+z)+x*x);
else
if(z==lz&&x<lx&&y<ly)
min=((x+z)*(x+z)+y*y)<((y+z)*(y+z)+x*x)?((x+z)*(x+z)+y*y):((y+z)*(y+z)+x*x);
else
{
if((x+y)*(x+y)+z*z<min)
min=(x+y)*(x+y)+z*z;
if((x+z)*(x+z)+y*y<min)
min=(x+z)*(x+z)+y*y;
if((y+z)*(y+z)+x*x<min)
min=(y+z)*(y+z)+x*x;
}
printf("%I64d\n",min);
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator