static Frac cal(int i, int j) { long x = a[i].x * a[j].x + a[i].y * a[j].y, y = a[i].x * a[i].x + a[i].y * a[i].y, z = a[j].x * a[j].x + a[j].y * a[j].y; Frac ans = new Frac(); ans.fz = x * x; ans.fm = y * z; if (x < 0) { ans.fz = -ans.fz; } return(ans); }
public Program(string inputFile, string outputFile) { io = new IOHelper(inputFile, outputFile, Encoding.Default); int n = io.NextInt(); a = new Vect[n]; for (int i = 0; i < n; i++) { a[i] = new Vect(); int x = io.NextInt(); int y = io.NextInt(); a[i].x = x; a[i].y = y; a[i].p = i + 1; if (x >= 0 && y >= 0) { a[i].t = 0; } else if (x < 0 && y > 0) { a[i].t = 1; } else if (x <= 0 && y <= 0) { a[i].t = 2; } else { a[i].t = 3; } } Array.Sort(a); int ansx = a[0].p, ansy = a[n - 1].p; Frac best = cal(0, n - 1); for (int i = 0; i < n - 1; i++) { Frac now = cal(i, i + 1); if (now > best) { ansx = a[i].p; ansy = a[i + 1].p; best = now; } } io.WriteLine(ansx + " " + ansy); io.Dispose(); }