2 12 0 1 0 3 1 3 1 4 2 4 2 5 4 5 4 3 3 3 3 2 2 2 2 1 4 4 0 4 2 6 2 7 0
The soap may belong to the bear ! The soap does not belong to the bear !





#include<iostream>
#include<cmath>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<string>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<ctime>
#include<bitset>
#define eps 1e-6
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define ll __int64
#define LL long long
#define lson l,m,(rt<<1)
#define rson m+1,r,(rt<<1)|1
#define M 1000000007
using namespace std;
#define Maxn 15
struct nod
{
double x;
double y;
}node[Maxn];
int visi[Maxn];
int main()
{
int t,n,i,j,k,l,p;
cin>>t;
while(t--)
{
cin>>n;
for(i=0;i<n;i++)
cin>>node[i].x>>node[i].y;
double x,y;
int flag=0;
nod p1,p2,p3;
for(i=0;i<n&&!flag;i++)
{
for(j=i+1;j<n&&!flag;j++)
{
memset(visi,0,sizeof(visi));
visi[i]=1;
visi[j]=1;
x=(node[i].x+node[j].x)/2;
y=(node[i].y+node[j].y)/2;
p1.x=node[j].x-node[i].x;
p1.y=node[j].y-node[i].y;
for(k=0;k<n;k++)
{
if(visi[k])
continue;
p2.x=node[k].x-x;
p2.y=node[k].y-y;
if(fabs(p1.x*p2.x+p1.y*p2.y)<eps)
{
visi[k]=1;
continue;
}
}
for(k=0;k<n;k++)
{
if(visi[k])
continue;
for(p=0;p<n;p++)
{
if(p==k||visi[p])
continue;
double x1,y1;
x1=(node[k].x+node[p].x)/2;
y1=(node[k].y+node[p].y)/2;
p2.x=x1-x;
p2.y=y1-y;
p3.x=node[k].x-node[p].x;
p3.y=node[k].y-node[p].y;
if(fabs(x1-x)<eps&&fabs(y1-y)<eps)
continue;
if(fabs(p1.x*p2.x+p1.y*p2.y)<eps&&fabs(p2.x*p3.x+p2.y*p3.y)<eps)
{
visi[k]=1;
visi[p]=1;
flag=1;
break;
}
}
}
int tt=0;
for(l=0;l<n;l++)
if(!visi[l])
tt=1;
if(tt==0) flag=1;
}
}
if(flag) puts("The soap may belong to the bear !");
else puts("The soap does not belong to the bear !");
}
return 0;
}
/*
23
6
4 2
4 0
4 -2
6 4
6 2
6 0
3
0 0
2 0
1 2
*/wust 1280What’ s Soapbear(简单计算几何),布布扣,bubuko.com
wust 1280What’ s Soapbear(简单计算几何)
原文:http://blog.csdn.net/coraline_m/article/details/22612531