Title Link: 12123-magnetic Train TracksTest Instructions: Given n points, ask for a few acute triangle. idea: And UVA 11529 is the same problem, enumerate one to do the origin, and then the rest of the point according to the origin of the polar sort, and then use the second pointer to go through, to find the angle is less than 90 degrees of acute angle, and then buckle down the number of obtuse triangle to get, And then, in total condition, the obtuse angle is sharp or right-angled.Code:
#include <stdio.h> #include <string.h> #include <math.h> #include <algorithm>using namespace Std;const double eps = 1e-9;const double pi = ACOs ( -1.0); const int N = 1205;int n;struct Point {double X, y;void read () {s CANF ("%lf%lf", &x, &y); }} P[n];d ouble r[n * 2];int C (int N, int m) {if (N < m) return 0;int ans = 1;for (int i = 0; i < m; i++) ans = ans * (n-i)/(i + 1); return ans;} Double Cal (Point A, point B) {return atan2 (B.Y-A.Y, b.x-a.x);} int solve (int num) {int tn = 0;for (int i = 0; i < n; i++) {if (i = = num) continue;r[tn++] = Cal (P[num], p[i]);} sort ( R, R + TN); for (int i = 0, i < TN; i++) R[tn + i] = R[i] + 2 * pi;int j = 1;int ans = 0;for (int i = 0; I < TN; i++) {while (FA BS (R[j]-r[i])-PI/2 <=-eps) J++;ans + = j-i-1; } return C (TN, 2)-ans;} int main () {int cas = 0;while (~scanf ("%d", &n) && N) {for (int i = 0; i < n; i++) p[i].read (); int ans = 0;f or (int i = 0; i < n; i++) ans + = solve (i);p rintf ("Scenario%d:\n", ++cas);p rintf ("There is%d sites for making valid tracks\n", C (n, 3)-ans); }return 0;}