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 gatesking at 2009-04-23 19:59:27 on Problem 1328
#include<iostream.h>
#include<math.h>

int main()
{
	float island[1001][2];
	float d,r,x,y,temp;
	int hascover[1001];
	int ncase,i,ii,num,time=0,yes=0;
	
	for(;;)
	{
		time++;
		yes=0;
		num=0;
		for(i=0;i<1001;i++)
			hascover[i]=0;
		cin>>ncase>>d;
		if((ncase==0)&&(d==0))
			break;
		if(d<0)
		{
			cout<<"Case "<<time<<": -1"<<endl;
			continue;
		}
		for(i=0;i<ncase;i++)
		{
			cin>>x>>y;
			if(y>d)
				yes=1;
			r=(float)sqrt(d*d-y*y);
			island[i][0]=x-r;
			island[i][1]=x+r;
		}
		if(yes==1)
		{
			cout<<"Case "<<time<<": -1"<<endl;
			continue;
		}
		for(i=ncase-1;i>=0;i--)
			for(ii=0;ii<i;ii++)
			{
				if(island[ii][1]>island[ii+1][1])
				{
					temp=island[ii][0];
					island[ii][0]=island[ii+1][0];
					island[ii+1][0]=temp;

					temp=island[ii][1];
					island[ii][1]=island[ii+1][1];
					island[ii+1][1]=temp;
				}
			}

		for(i=0;i<ncase;i++)
		{
			if(hascover[i]==0)
			{
				num++;
				for(ii=0;ii<ncase;ii++)
				{
					if(island[ii][0]<=island[i][1])
						hascover[ii]=1;
				}
			}
		}
		cout<<"Case "<<time<<": "<<num<<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