Home > other >  Why POJ1328 radar installations, for help always WA
Why POJ1328 radar installations, for help always WA

Time:11-05

There are a great god help have a look at the code?
The original link to http://poj.org/problem? Id=1328

 
#include
#include
using namespace std;
Int n, d;
Int a [1000] [2].
Double x [1000], [2].
Double temp.
Int main ()
{
Int num=0;
Cin & gt;> N & gt;> d;
While (n & amp; & D)
{
Num++;
Bool flag=true;
for (int i=0; I & lt; n; I++)
Cin & gt;> [I] a [0] & gt;> A, [I] [1].

for (int i=0; I & lt; n; I++)
{
If (abs (a [I] [1]) & gt; Abs (d))
{
cout <"Case" & lt; Flag=false;
break;
}
}
If (flag)
{
for (int i=0; I & lt; n; I++)//calculation for each island, the radar can be placed the coordinates of the scope of the
{
Double move=SQRT (double (d * d - a [I] a [I] [1] * [1]));
[I] x [0]=[I] a [0] - a move;
[I] x [1]=[I] a [0] + move;
}
for (int i=0; I & lt; N - 1; Bubble sort i++)//
{
For (int j=n - 1; J & gt; i; J -)
{
If (x [j] [0] {
Temp=x [j] [0];
X [j] [0]=x [1] [0];
X [1] [0]=temp;
Temp=x [j] [1];
X [j] [1]=x [1] [1];
X [1] [1]=temp;
}
}
}
Int LD=1;
Temp=x [0] [1].
For (int I=1; I & lt; n; I++)
{
If (x [I] [0] <=temp)
{
If (x [I] [1] Temp=x [I] [1];
}
The else
{
LD++;
Temp=x [I] [1];
}
}
cout <"Case" & lt; }
Cin & gt;> N & gt;> d;
}
return 0;
}
  • Related