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

高手帮帮忙!!!我的程序哪里错了阿!!!总是wrong

Posted by acmHLJ at 2007-09-10 12:25:46 on Problem 1106
#include<iostream>
#include<cmath>
using namespace std;

#define pi 3.1415926
int result[100];
int flag = 0;


int main()
{
	int tranX, tranY;
	int N, i;
	double r;
	while(true)
	{
		int tot = 0;
		double proA = 0, A;
		cin>>tranX>>tranY; 
		cin>>r;
		if(r<= 0)
			break;
		cin>>N;
		int* X = new int [N];
		int* Y = new int [N];
		for(i = 0; i < N; i++)
			cin>>X[i]>>Y[i];
		while(true)
		{
			double k = 0;
			double tempA = 0;
			int tempi= 0;
			int jud = 0;
			A =  pi+1;
			for(i = 0; i < N; i++)
			{
				if(X[i] == tranX)
					tempA = pi/2;
				else
				{
					k = (double)(Y[i]-tranY)/(X[i]-tranX);
					if(k >= 0)
						tempA = atan(k);
					else
						tempA = pi + atan(k);
				}	
				if(A>tempA && tempA>proA)
				{	
					A = tempA;
					tempi = i;
					jud = 1;		
				}
			}
			if(jud == 0)
				break;
			proA = A;
			
			int remNum = 0;
			for(i = 0; i < N; i++)
			{
				double isOver = (tranX - X[i])*(Y[tempi]-tranY)-(X[tempi]-tranX)*(tranY-Y[i]);
				double disT  = sqrt(pow(X[i]-tranX, 2) + pow(Y[i]-tranY, 2));
				if(isOver>=0&&disT<=r)
					remNum++;
			}
			if(tot < remNum)
				tot = remNum;	
		}
		result[flag] = tot;
		flag++;		
		delete [] X;
		delete [] Y;
	}
	for(i = 0; i < flag;i++)
		cout<<result[i]<<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