链接:https://acm.bnu.edu.cn/v3/statments/52296.pdf
一个点到一个立方体的距离就是到各个边的最短距离
#include<stdio.h>
int main()
{
int x,y,z;
int x1,y1,z1;
int x2,y2,z2;
scanf("%d%d%d",&x,&y,&z);
scanf("%d%d%d",&x1,&y1,&z1);
scanf("%d%d%d",&x2,&y2,&z2);
int sum=0;
if(x1<=x&&x<=x2&&y1<=y&&y<=y2&&z1<=z&&z<=z2)
{
printf("0\n");
}
else
{
if(x>x2) sum+=(x-x2)*(x-x2);
else if(x<x1) sum+=(x-x1)*(x-x1);
if(y>y2) sum+=(y-y2)*(y-y2);
else if(y<y1) sum+=(y-y1)*(y-y1);
if(z>z2) sum+=(z-z2)*(z-z2);
else if(z<z1) sum+=(z-z1)*(z-z1);
printf("%d\n",sum);
}
return 0;
}