2571.txt

来自「北大ACM题目例程 详细的解答过程 程序实现 算法分析」· 文本 代码 · 共 51 行

TXT
51
字号
Problem Id:2571  User Id:fzk 
Memory:36K  Time:15MS
Language:C++  Result:Accepted

Source 

#include"stdio.h"
#include"math.h"
#define pi 3.1415926535898


void change( double th,double fi, double l, double &x, double &y, double &z )
{
	z = l * sin( th/180*pi );
	y = l * cos( th/180*pi ) * sin( fi/180*pi );
	x = l * cos( th/180*pi ) * cos( fi/180*pi );
}


int main()
{
	double x, y, z, a, b, c, th, fi, l;
	int n,i,cas=1;
	char name[100];

	while( 1 )
	{
		scanf( "%d", &n );
		if( n == 0 ) break;

		printf( "Test case %d:\n", cas++ );

		scanf( "%lf %lf %lf", &th, &fi, &l );
		l += 6378;
		change( th, fi, l, x, y, z );

		for( i=0; i<n; i++ )
		{
			scanf( "%s %lf %lf", name, &th, &fi );
			change( th, fi, 6378, a, b, c );

			if( (x-a)*a + (y-b)*b + (z-c)*c >= 0 )	printf( "%s\n", name );
		}

		printf( "\n" );
	}
	return 0;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?