Home > Back-end >  Sprinkler systems - greed question...
Sprinkler systems - greed question...

Time:10-01

Title, as shown on the left side of the code is written by myself, error rate by 83%, then the code on the right is my reference other bosses code changes, after two code only green box is not the same,,,, I really want to know where is wrong, my own code, test several times didn't find his mistakes,,

CodePudding user response:

 
# include & lt; Cstdio>
# include & lt; Cmath>
# include & lt; Algorithm>
using namespace std;
Const int maxn=610;
Double r [610];
Bool CMP (double x, double y)
{
Return x> y;
}
Double count (double) p
{
Double t;
T=2 * SQRT (p * p - 1 * 1);
return t;
}
Int main ()
{
Int m, n, I, c;
Double len.
The scanf (" % d ", & amp; M);
While (m -)
{
The scanf (" % d ", & amp; n);
for(i=0; ILf the scanf (" % ", & amp; R );
Sort (r, r + n, CMP);
Len=0;
c=0;
for(i=0; I{
Len +=count (r [I]);
C + +;
If (len>=20) break;
}
Printf (" % d \ n ", c);
}
return 0;
}

[I] this is
  • Related