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

哪位大神,给小弟一些错误的测试数据,不胜感激,总是runtime Error

Posted by dreamvyps at 2010-08-23 14:38:19 on Problem 1328 and last updated at 2010-08-23 14:39:53
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std; 
struct range
{
	double start; 
	double end; 
};

range rang_t[1000]; 

bool cmp(const range& a,const range& b)
{
	return a.start > b.start; 
}; 
int main()
{
	
	int n = 0,d = 0; 
	int x = 0,y = 0; 
	int num = 1; 
	for (;cin >> n >> d;++num)
	{
		if (n == 0)
		{
			break; 
		}
		if (n == 1)
		{
			cin >> x >> y; 
			if (y > d || d <= 0 || y < 0)
			{
				cout << "Case " << num <<": " << "-1" << endl; 
			}
			else
				cout << "Case " << num <<": " << "1" << endl; 
			continue; 
		}
		for (int i = 1; i <= n;++i)
		{
			cin >> x >> y; 
			rang_t[i].start = x - sqrt((double)(d*d - y*y)); 
			rang_t[i].end = x + sqrt((double)(d*d - y*y)); 
		}
		


		sort(rang_t,rang_t+n,cmp); 
		int counter = 1; 
		int cur = rang_t[1].end; 
		for (int i = 2; i <= n; ++i)
		{
			if (cur < rang_t[i].start)
			{
				counter++; 
				cur = rang_t[i].end; 
			}
			if (cur > rang_t[i].end)
			{
				cur = rang_t[i].end; 
			}
		}
		cout << "Case " << num <<": " << counter << 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