1293: "The Tower Kang" the navigation systemTime limit: 2 Sec Memory limit: 128 MB
Submitted: 208 Settlement: 71
Submitted State [Discussion Version]
Topic Description
"Tower Kang" (tacan-tactical Air navigation system) is a tactical aerial navigation systems abbreviation, by the United States in 1955 successfully developed, after the French, Germany, Britain, Canada, Japan, Korea and other widely used. Mainly used for shipboard aircraft to provide from tens meters to kilometers meters distance within the range of navigation, to ensure that the aircraft on the scheduled route to the target, the cluster of aerial assembly, as well as in the complex meteorological conditions to guide the aircraft homing and entry and so on.
This is a polar coordinate radio aerial navigation system, when the flagship is set to the origin of the coordinates, the carrier aircraft can be obtained from the coordinates of the origin of the angle and distance, thus positioning.
But the positioning system now used by a fleet is X-y coordinates, and the fleet commander needs you to write a program to calculate the distance between the ship's current location and its flagship and the angle of the angle relative to the x-axis, in order to use the "Tower Kang" navigation system to navigate the shipboard aircraft.
input
There are multiple sets of test data. The first behavior is an integer t that indicates that there is a T group of test data. Enter two integers x and y at the beginning of each set of data, representing the flagship's coordinates. then enter an integer n (1≤n≤100), indicating that there are N-carrier aircraft, followed by n-line input, two integers xi and Yi ( -1000≤xi,yi≤1000) per line, representing the coordinates of the I-carrier aircraft.
Output
The
Outputs n rows, outputting two real numbers per line, representing the angle R (0 <= R <= 90) between the first n carrier and the flagship relative to the X axis, and the distance from the flagship (two digits rounded to the decimal point). See the sample for the exact format of the output. Sample Input 022 2-1 -30 021 2 Sample output 45.00 deg / 2.83 km 71.57 deg / 3.16 km 63.43 deg / 2.24 km 45.00 deg / 2.83 km
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const double pi=3.1415927;
int main ()
{
int a[110],b[110],t,n,i;
Double k,m,j;
while (CIN >> T)
{while
(t--)
{
cin >> a[0] >> b[0];
CIN >> N;
for (i=1;i<=n;i++)
{
cin >> A[i] >> b[i];
}
for (i=1;i<=n;i++)
{
j=sqrt (a[i]-a[0]) * (a[i]-a[0)) + (b[i]-b[0)) * (b[i]-b[0));
K= (ABS (A[i]-a[0]))/j;
M=acos (k) * (180.0/PI);
cout << setiosflags (ios::fixed) << setprecision (2) << m << "DEG/";
cout << J << "KM" << Endl
}}
return 0;
}