BestCoder Round #50 (div.2) HDU 5365 Run(简单几何)

题目链接: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.
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.
 

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方格线上有一些点,问能找到多少个正三角形,正方形,正五边形,正六边形。

解题:
    做的时候,已经猜到可能只有正方形才是可以的,只是来不及了,题解却说地球人都知道,无爱了....
    数据量这么小,怎么暴力怎么来咯!

代码:
#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;
}




  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值