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 jsmingzi at 2009-07-18 20:25:55 on Problem 1328
In Reply To:通过此题,我对poj彻底绝望了…… Posted by:sanding at 2009-04-19 23:28:16
#include <iostream>
#include <cmath>
using namespace std;

struct range{
	double ranges,ranget;
};

range rang[1000];

int cmp(const void *pt1,const void *pt2)
{
	return (*(range*)pt1).ranges - (*(range*)pt2).ranges;
}

int main()
{
	int n,d,cases=0;
	for(cases=1;cin>>n>>d&&n;cases++)
	{
		int i;
		bool flag=false;
		double x,y;
		for(i=0;i<n;i++)
		{
			cin>>x>>y;
			if(y>d) flag=true;
			else
			{
				rang[i].ranges=x-sqrt(d*d-y*y);
				rang[i].ranget=x+sqrt(d*d-y*y);
			}
		}
		if(flag)
		{
			cout<<"Case "<<cases<<": -1"<<endl; continue;
		}

		qsort(rang,n,sizeof(range),cmp);

	
		int cirnums=0;
		double s,t;
		for(i=0;i<n;i++)
		{
			if(!i)
			{
				s=rang[i].ranges;
				t=rang[i].ranget;
				cirnums++;
			}
			else if(rang[i].ranges<=t)
			{
				s=rang[i].ranges;
				t=t<rang[i].ranget?t:rang[i].ranget;
			}
			else
			{
				s=rang[i].ranges;
				t=rang[i].ranget;
				cirnums++;
			}
		}
		cout<<"Case "<<cases<<": "<<cirnums<<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