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 894212550 at 2013-11-14 16:13:32 on Problem 1328
#include "iostream"
#include "cstdio"
#include "algorithm"
#include "cmath"
using namespace std;

struct area{
	int x,y;
	double l,r;
}island[1001];

int cmp(area x,area y){
	return x.l<y.l;
}

int rid,least,temp_r,out;

int account(int xx,int yy,int i){
	if(rid<0) return 0;
	double temp=rid*rid-yy*yy;
	if(temp<0) return 0;
	temp=sqrt(temp);
	island[i].l=xx-temp;
	island[i].r=xx+temp;
	return 1;
}

int main(){
	int count;
	int i,n=0;
	while(scanf("%d%d",&count,&rid) && (count || rid)){
		for(i=0;i<count;i++){
			scanf("%d%d",&island[i].x,&island[i].y);
		}
		for(i=0;i<count;i++){
			out=account(island[i].x,island[i].y,i);
			if(!out) break;
		}
		if(!out) least=-1;
		else{
			sort(island,island+count,cmp);
			i=0;least=0;
			while(i<count){
				for(temp_r=island[i].r;island[i].l<=temp_r && i<count;i++) if(island[i].r<temp_r)temp_r=island[i].r;
				least++;
			}
		}
		printf("Case %d: %d\n",++n,least);
	}
	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