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

那位有此题的测试数据,可不可以让我看一下,我做的总是wa,而题上的测试数据,在我的代码中运行有总是对的。我的代码如下,如果那位高人看到,可以帮忙指点以下!万分感谢!

Posted by holding at 2007-08-12 22:55:40 on Problem 1375
#include<stdio.h>
#include<math.h>
#include<algorithm>
#define MAX 501

using namespace std;

typedef struct Node
{
	int k1;
	int k2;
}xielu;

bool mycmp(const Node & a, const Node & b)
{
   return a.k1<b.k1;
}

int main()
{
	int tt;
	Node data[MAX];
	scanf("%d",&tt);
	while(tt)
	{
		int bx,by,aa;
		int cx[MAX],cy[MAX],r[MAX];
		int a[MAX],b[MAX];
		scanf("%d%d",&bx,&by);
		int i,j;
		for(i=1;i<=tt;i++)
		{
			scanf("%d%d%d",&cx[i],&cy[i],&r[i]);
			aa=cx[i]=cx[i]-bx;
			cx[i]=abs(cx[i]);
			cy[i]=by-cy[i];
			if(cx[i]==r[i])
			{
				a[i]=bx*100;
				b[i]=(int)(bx*100.0-2*aa*cy[i]*by*100.0/(r[i]*r[i]-cy[i]*cy[i])+0.5);
				if(a[i]<b[i])
				{	data[i].k1=a[i]; data[i].k2=b[i];}
				else
				{	data[i].k2=a[i]; data[i].k1=b[i];}
			}
			else
			{
				a[i]=(int)(bx*100.0-2*(cx[i]*cx[i]-r[i]*r[i])*by*100.0/(-2*aa*cy[i]+2*sqrt(cx[i]*cx[i]*cy[i]*cy[i]-(cy[i]*cy[i]-r[i]*r[i])*(cx[i]*cx[i]-r[i]*r[i])))+0.5);
				b[i]=(int)(bx*100.0-2*(cx[i]*cx[i]-r[i]*r[i])*by*100.0/(-2*aa*cy[i]-2*sqrt(cx[i]*cx[i]*cy[i]*cy[i]-(cy[i]*cy[i]-r[i]*r[i])*(cx[i]*cx[i]-r[i]*r[i])))+0.5);
				if(a[i]<b[i])
					{	data[i].k1=a[i]; data[i].k2=b[i];}
				else
					{	data[i].k2=a[i]; data[i].k1=b[i];}
			}
		}
		sort(data,data+tt,mycmp);
		for(i=2,j=1;i<=tt;i++)
		{
			if(data[i-1].k2<data[i].k1)
			{	printf("%.2f %.2f\n",data[j].k1/100.0,data[i-1].k2/100.0);j=i;}
		}
		printf("%.2f %.2f\n",data[j].k1/100.0,data[i-1].k2/100.0);
		printf("\n");
		scanf("%d",&tt);	
	}
	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