hdu5365Run 暴力

//给n个坐标,问能构成多少个不同的正三边形,正四边形,正五边形,正六变形
//题解说地球人都知道整点是不能构成正五边形和正三边形和正六边形的,
//然后就只需要暴力找正四边形
//突然感觉原来我不是地球人

include

include

include

include

using namespace std ;

define dis(a,b,c,d) (((a-b)(a-b) + (c-d)(c-d)))

const int maxn = 30 ;
double x[maxn] , y[maxn];
double len[maxn] ;
bool judge(int i , int j , int k , int s)
{
len[0] = sqrt(dis(x[i],x[j],y[i],y[j]));//i j 0
len[1] = sqrt(dis(x[i],x[k],y[i],y[k]));//i k 1
len[2] = sqrt(dis(x[i],x[s],y[i],y[s]));//i s 2
len[3] = sqrt(dis(x[j],x[k],y[j],y[k]));//j k 3
len[4] = sqrt(dis(x[j],x[s],y[j],y[s]));//j s 4
len[5] = sqrt(dis(x[k],x[s],y[k],y[s]));//k s 5
if(len[0] == len[5] && len[1] == len[2] && len[3] == len[4] && len[1] == len[3])
return true ;
if(len[1] == len[4] && len[0] == len[2] && len[3] == len[5] && len[0] == len[3])
return true ;
if(len[2] == len[3] && len[0] == len[1] && len[4] == len[5] && len[0] == len[4])
return true ;
return false ;
}
int main()
{
int n ;
while(~scanf(“%d” , &n))
{
for(int i = 1;i <= n;i++)
scanf(“%lf%lf” , &x[i] , &y[i]);
int ans = 0;
for(int i = 1;i <= n;i++)
for(int j = i+1;j <= n;j++)
for(int k = j+1;k <= n;k++)
for(int s = k+1;s <= n;s++)
if(judge(i,j,k,s))
ans++ ;
cout<

你可能感兴趣的:(暴力)