## Friday, December 2, 2016

### HDU 5365 Run - BestCoder Round #50(div.1 div.2)

http://acm.hdu.edu.cn/showproblem.php?pid=5365
AFA is a girl who like runing.Today,she downloaded an app about running .The app can record the trace of her runing.AFA will start runing in the park.There are many chairs in the park,and AFA will start her running in a chair and end in this chair.Between two chairs,she running in a line.she want the the trace can be a regular triangle or a square or a regular pentagon or a regular hexagon.
Please tell her how many ways she can find.
Two ways are same if the set of chair that they contains are same.
Input
There are multiply case.
In each case,there is a integer n(1 < = n < = 20)in a line.
In next n lines,there are two integers xi,yi(0 < = xi,yi < 9) in each line.
Output
Output the number of ways.
Sample Input
```
4
0 0
0 1
1 0
1 1
```
Sample Output
```
1
```

http://blog.csdn.net/queuelovestack/article/details/47364285

NO的斜率=

1. const int N = 25;
2. const int inf = 1000000000;
3. const int mod = 1000000007;
4. int x[N],y[N],s[6];
5. int sqare(int x1,int y1,int x2,int y2)
6. {
7.     return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
8. }
9. bool judge(int i,int j,int k,int l)
10. {
11.     int t=0;
12.     s[t++]=sqare(x[i],y[i],x[j],y[j]);
13.     s[t++]=sqare(x[j],y[j],x[k],y[k]);
14.     s[t++]=sqare(x[k],y[k],x[l],y[l]);
15.     s[t++]=sqare(x[l],y[l],x[i],y[i]);
16.     s[t++]=sqare(x[i],y[i],x[k],y[k]);
17.     s[t++]=sqare(x[l],y[l],x[j],y[j]);
18.     sort(s,s+6);
19.     if(s[0]==s[1]&&s[2]==s[3]&&s[1]==s[2]&&s[4]==2*s[0]&&s[5]==s[4])
20.         return true;
21.     return false;
22. }
23. int main()
24. {
25.     int n,i,j,k,l,t;
26.     while(~scanf("%d",&n))
27.     {
28.         t=0;
29.         for(i=1;i<=n;i++)
30.             scanf("%d%d",&x[i],&y[i]);
31.         for(i=1;i<=n;i++)
32.             for(j=i+1;j<=n;j++)
33.                 for(k=j+1;k<=n;k++)
34.                     for(l=k+1;l<=n;l++)
35.                         if(judge(i,j,k,l))
36.                             t++;
37.         printf("%d\n",t);
38.     }
39.     return 0;
http://www.cnblogs.com/Emerald/p/4720631.html

http://www.voidcn.com/blog/aaaaacmer/article/p-4310045.html

https://my.oschina.net/sunshinedabby/blog/57529
在做ACM题目的时候,遇到了要求输入四个点的坐标,然后判断这四个点能否构成一个正方形.这个看似很简单,但细节方面还是有许多问题的.我想的方法很容易理解,而且一次就AC了.
首先,我先选定三个点,判断这三个点是否可以构成一个等腰直角三角形(如果不是的话,肯定无法构成正方形的),在判断的同时,还要确定一下三个点(主要是直角的那个点);这样确定后,再利用第四个点验证一下就容易了.这题要求的是穷举法,我想在万不得已的情况下才会考虑这样的方法的.不过,作为初学者练习穷举法的使用技巧还是很推荐使用.
bool Judge(Coordinate const x,Coordinate const y,Coordinate const z)
{
Coordinate *mVector = new Coordinate(x.xCoordinate - y.xCoordinate,
x.yCoordinate - y.yCoordinate);
Coordinate *nVector = new Coordinate(z.xCoordinate -
(x.xCoordinate + y.xCoordinate)/2,
z.yCoordinate -
(x.yCoordinate + y.yCoordinate)/2);
//判断是否为等腰三角形
bool result = ((mVector->xCoordinate * nVector->xCoordinate +
mVector->yCoordinate * nVector->yCoordinate) == 0);

//判断是否是直角三角形
if(result)
result = (mVector->xCoordinate * mVector->xCoordinate +
mVector->yCoordinate * mVector->yCoordinate)
== ((nVector->xCoordinate * nVector->xCoordinate +
nVector->yCoordinate * nVector->yCoordinate) * 4);

delete mVector;
delete nVector;

return result;
}

/**
* @explanation 给定四个坐标点,判断这四个坐标点是否为一个正方形上的四点.
* @algorithm  任意选定三点,判断是否为等腰直角三角形(确定直角的位置);
* 然后再利用另外一个点来验证.
*/
bool IsSquare(Coordinate *array,int length)
{
if(length != 4)
return false;
int a,b,c;

if(Judge(array[0],array[1],array[2]))
{
a = 0;
b = 1;
c = 2;
}
else if(Judge(array[0],array[2],array[1]))
{
a = 0;
b = 2;
c = 1;
}
else if(Judge(array[2],array[1],array[0]))
{
a = 1;
b = 2;
c = 0;
}
else
return false;

return (array[3] != array[c] && Judge(array[a],array[b],array[3]));
}

http://blog.csdn.net/u011394362/article/details/40141929

https://www.zhihu.com/question/25304120?rf=34324133