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

请高手帮忙看看!

Posted by 170532934 at 2008-10-06 17:01:19 on Problem 1328
为什么老是wa?我不知道哪里错了啊!谢谢啦!

#include "iostream"
#include<math.h>
using namespace std;
struct node
{
int x,y;
};
int _tmain(int argc, _TCHAR* argv[])
{
	int a[1000],l=0,ii;
	bool tag;
	int num=0;
	while(1){
int n,d;
tag=false;
num=0;
node temp,now;
cin>>n>>d;
if(n==0&&d==0)break;
if(d<=0){a[l++]=-1;}
node *p=new node[n];
int i,j;
for(i=0;i<n;i++)
{cin>>p[i].x>>p[i].y;if(abs(p[i].y)>d&&d>0)tag=true;}
if(tag==true){a[l++]=-1;continue;}
if(d>0)
{
for(i=0;i<n;i++)
{	for(j=i+1;j<n;j++)
		if(p[i].x>p[j].x){ temp=p[i]; p[i]=p[j]; p[j]=temp; }
}
now=p[0];
j=n;
int max1=1;
int r,t,k=1;
while(j!=0)
{
for(i=n-j;i<n;i++)
if((p[i].x-now.x)>d*2) break;
for(r=now.x;r<=p[i-1].x;r++)
 {
 for(t=n-j+1;t<i;t++)
	 if((r-p[t].x)*(r-p[t].x)+p[t].y*p[t].y<=d*d) k++;
 if(max1<k)max1=k;
 k=1;
 }
 j=j-max1;
 max1=1;
 num++;
now=p[n-j];
 k=1;
};
a[l++]=num;}
	};
	for(ii=0;ii<l;ii++)
		cout<<"Case "<<ii+1<<": "<<a[ii]<<endl;
	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