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

为什么一直WA啊~莫非是精度问题~大牛来看一看啊

Posted by justjude at 2007-10-02 19:06:53 on Problem 3407
#include <iostream>
#include <math.h>

#define pi acos(-1.0)
#define r 6370
#define sq(x) ((x)*(x))
#define ss (2*(pi)*(r))

using namespace std;

double wd[3],wf[3],jd[3],jf[3] , w , j;
double a,b,x[3],y[3],z[3];
char ns[20],we[20];

int main ()
{
	int i;
	for( i = 1 ; i < 3 ; i++ )
	{
		cin>>wd[i]>>wf[i]>>ns[i]>>jd[i]>>jf[i]>>we[i];
		w = wd[i] + wf[i] / 60;
		if (ns[i] == 'S' && w < 90) 
			w = -w;
		w = w * ( pi / 180 );
		j = jd[i] + jf[i] / 60;
		if (we[i] == 'W' && j < 180) 
			j = -j;
		j = j * ( pi / 180 );
		z[i]=r*sin(w);
		x[i]=r*cos(j)*cos(w);
		y[i]=r*sin(j)*cos(w);
	}
	b=(sq(r)*2-(sq(z[1]-z[2])+sq(x[1]-x[2])+sq(y[1]-y[2])))/(2*sq(r));
	a=acos(b);
	b=a*r;
	if(b>ss/2)b=ss-b;
	printf ("%0.6lf\n",b);
	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