Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

tell me why

Posted by sunwen at 2008-02-23 11:32:33 on Problem 1034
#include<stdio.h>
#include<math.h>
int rout[202][2],Bob[101][2],interesting[101][2],p,flag[101]={0};
int sum(int m,int n,float lenB)
{
	float l,r;
	l=sqrt(pow(interesting[m][0]-Bob[n][0],2)+pow(interesting[m][1]-Bob[n][1],2));
	r=sqrt(pow(interesting[m][0]-Bob[n+1][0],2)+pow(interesting[m][1]-Bob[n+1][1],2));
	if(l+r>lenB) return 0;
	else return 1;
}
int search(int n,int m)
{
	int i;
	float len,lenB;
	len=sqrt(pow(Bob[n][0]-Bob[n+1][0],2)+pow(Bob[n][1]-Bob[n+1][1],2));
	lenB=2*len;
	for(i=0;i<m;i++)
	{
		if(flag[i]!=1&&sum(i,n,lenB))               // 狗走过的就不能在走了flag[i]标记 可是不对 如果走过的可以走 我是了也不对 
		{
			p=i;
			flag[i]=1;
			return 1;
		}
	}
	return 0;
}
int main()
{
	int i,j,n,m,k=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
		scanf("%d%d",&Bob[i][0],&Bob[i][1]);
	for(i=0;i<m;i++)
		scanf("%d%d",&interesting[i][0],&interesting[i][1]);
	for(i=0;i<n-1;i++)
	{
		rout[k][0]=Bob[i][0];
		rout[k][1]=Bob[i][1];
		k++;
		if(search(i,m))
		{
			rout[k][0]=interesting[p][0];
			rout[k][1]=interesting[p][1];
			k++;
		}
	}
	printf("%d\n",k+1);
	for(i=0;i<k;i++)
	{
		printf("%d %d ",rout[i][0],rout[i][1]);
	}
	printf("%d %d\n",Bob[n-1][0],Bob[n-1][1]);
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator