简单计数问题,但比较诡异的是WA后,将printf输出改为cout输出就AC了,又或者保持printf输出但改为比较距离(原本是比较距离的平方)也可以AC。具体原因不详……
Run Time: 0sec
Run Memory: 304KB
Code length: 758Bytes
SubmitTime: 2011-12-20 19:39:17
// Problem#: 1961
// Submission#: 1099981
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <cstdio>
#include <cmath>
using namespace std;
struct Coor {
double x;
double y;
double z;
};
int main()
{
int T, N;
Coor p, s, keep;
double closest;
scanf( "%d", &T );
while ( T-- ) {
scanf( "%lf%lf%lf", &p.x, &p.y, &p.z );
scanf( "%d", &N );
scanf( "%lf%lf%lf", &s.x, &s.y, &s.z );
closest = powl( p.x - s.x, 2 ) + powl( p.y - s.y, 2 ) + powl( p.z - s.z, 2 );
keep = s;
while ( --N ) {
scanf( "%lf%lf%lf", &s.x, &s.y, &s.z );
if ( powl( p.x - s.x, 2 ) + powl( p.y - s.y, 2 ) + powl( p.z - s.z, 2 ) < closest ) {
closest = powl( p.x - s.x, 2 ) + powl( p.y - s.y, 2 ) + powl( p.z - s.z, 2 );
keep = s;
}
}
printf( "(%.2lf, %.2lf, %.2lf) %.2lf\n", keep.x, keep.y, keep.z, sqrtl( closest ) );
}
return 0;
}