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

Re:看不出哪里有问题,求救啊

Posted by peerlessbloom at 2014-02-20 09:23:02 on Problem 1328
In Reply To:看不出哪里有问题,求救啊 Posted by:894212550 at 2013-11-14 16:13:32
#include "iostream"
#include "cstdio"
#include "algorithm"
#include "cmath"
using namespace std;

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

int cmp(const void* a,const void* b){
	area * x = (area*)a;
	area * y = (area*)b;
	if (fabs(x->l - y-> l) < 0.00001)
		return 0;
	else if (x->l < y->l)
		return -1;
	return 1;
}

int rid,least,out;
double temp_r;

int account(double xx,double 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("%lf%lf",&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{
			qsort(island,count, sizeof(area),cmp);
			i=0;least=1;
			temp_r=island[i].r;
			while(i<count){
				if (temp_r - island[i].r>0.000000001)
					temp_r = island[i].r;
				if (island[i].l - temp_r > 0.00000001)
				{
					temp_r=island[i].r;
					least++;
				}
				i++;
			}
		}
		printf("Case %d: %d\n",++n,least);
	}
	return 0;
}
问题:d=0时
temp_r应该是double

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