题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5365
题面:(严重吐槽,看着真不舒服,还是改一下吧)
Run
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 549 Accepted Submission(s): 245
Problem Description
AFA is a girl who like
s run
ning. Today,
she download
ed an app about run
ning .The app can record the trace of her run
ning. AFA will start run
ning in the park. There are many chairs in the park, and AFA will start his(
her) run
ning in a chair and end in this(
another) chair. Between two chairs,she running(
runs) in a line. she(
She) want
s the(
/) the trace can (
to) be a regular triangle or a square or a regular pentagon or a regular hexagon.
Please tell her how many ways can her( she) find.
Two ways are same if the set of chair that they contains are same.
Please tell her how many ways can her( she) find.
Two ways are same if the set of chair that they contains are same.
Two ways are same if chairs that two sets contains are the same.
Input
There are multiply(
multiple) case
s.
In each case,there is a n 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.
In each case,there is a n 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
Source
BestCoder Round #50 (div.2)
题目大意:
再给定的9*9方格线上有一些点,问能找到多少个正三角形,正方形,正五边形,正六边形。
解题:
做的时候,已经猜到可能只有正方形才是可以的,只是来不及了,题解却说地球人都知道,无爱了....
数据量这么小,怎么暴力怎么来咯!
代码:
题目大意:
再给定的9*9方格线上有一些点,问能找到多少个正三角形,正方形,正五边形,正六边形。
解题:
做的时候,已经猜到可能只有正方形才是可以的,只是来不及了,题解却说地球人都知道,无爱了....
数据量这么小,怎么暴力怎么来咯!
代码:
#include <stdio.h>
#include <iostream>
#include <cstring>
using namespace std;
struct point
{
int x,y;
}store[25];
//该位置是否有点标记
bool status[10][10];
//判断是否出界
bool inside(int x,int y)
{
if(x>=0&&x<9&&y>=0&&y<9)
return true;
else
return false;
}
int main()
{
int t,tx1,ty1,tx2,ty2,tx3,ty3,ans,xd,yd;
while(~scanf("%d",&t))
{
memset(status,0,sizeof(status));
ans=0;
for(int i=0;i<t;i++)
{
scanf("%d %d",&store[i].x,&store[i].y);
//标记
status[store[i].x][store[i].y]=1;
}
for(int i=0;i<t-1;i++)
{
for(int j=i+1;j<t;j++)
{
tx1=store[i].x;
tx2=store[j].x;
ty1=store[i].y;
ty2=store[j].y;
xd=tx1-tx2;
yd=ty1-ty2;
//所有点枚举
for(int k=0;k<=8;k++)
{
for(int m=0;m<=8;m++)
{
//该位置有点
if(status[k][m])
{
//且不是枚举的两个点
if((k==tx1&&m==ty1)||(k==tx2&&m==ty2))
continue;
//垂直
if((xd*(k-tx2)+yd*(m-ty2))==0)
{
//距离相等
if(((k-tx2)*(k-tx2)+(m-ty2)*(m-ty2))==(xd*xd+yd*yd))
{
tx3=k+xd;
ty3=m+yd;
//第四个点在界内,且存在
if(inside(tx3,ty3)&&status[tx3][ty3])
ans++;
}
}
}
}
}
}
}
//一个正方形四条边都会计算一次
ans/=4;
printf("%d\n",ans);
}
return 0;
}