I’ve tried just about everything I can think of to solve this, but I’m still getting “wrong answer” from the judge. From what I can gather, the input is malformed somewhere, but as far as I know scanf ignores whitespace. Where did I go wrong?
#include <stdio.h>
#include <math.h>
int main () {
int test_cases = 0, planets = 0, coordinates[2], farthest = 0, sum;
double farthest_value = 0, square_root;
scanf("%i", &test_cases);
for (int i = 1; i <= test_cases; i++){
scanf("%i", &planets);
for (int j = 1; j <= planets; j++){
scanf("%i%i", &coordinates[0], &coordinates[1]);
for (int k = 0; k < 2; k++){
coordinates[k] = coordinates[k] * coordinates[k];
}
sum = coordinates[0] + coordinates[1];
square_root = sqrt(sum);
if (square_root > farthest_value) {
farthest = j;
farthest_value = square_root;
}
}
printf("Case %i: %i\n", i, farthest);
}
return 0;
}