Hdu4082 Hou Yi's secret brute force

Source: Internet
Author: User

Http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 4082

Hou Yi's secret Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 3006 Accepted Submission (s): 710


Problem DescriptionLong long ago, in the time of Chinese emperor Yao, ten suns rose into the sky. They burned the crops and scorched the bushes and trees, leaving the people with nothing to eat.

Hou Yi was the greatest archer at that time. yao wanted him to shoot down nine suns. hou Yi couldn't do that job with ordinary arrows. so Yao send him to God to get some super powerful magic arrows. before Hou Yi left, Yao said to him: "In order to manage our country in a better way, I want to know how many years can I live from now on. please ask God this question for me. "Hou Yi promised him.
Hou yi came back from God with ten magic arrows. he shot down nine suns, and the world returned to harmony. when Yao asked Hou Yi about the answer of his question, Hou Yi said: "God told me nothing. but I happened to see a 'Life and death book' with your name on it. so I know the answer. but you know, I can't tell you because that's God's secret, and anyone who gives out God's secret will be burned By a thunder! "
Yao was very angry, he shouted: "But you promised me, remember? "Hou Yi said:
"Ooo-er, let's make some compromise. I can't tell you the answer directly, but I can tell you by my only precious magic arrow. i'll shoot the magic arrow several times on the ground, and of course the arrow will leave some holes on the ground. when you connect three holes with three line segments, you may get a triangle. the maximum number of similar triangles you can get means the number of years you can live from now on. "(If the angles of one triangle are equal to the angles of another triangle respectively, then the two triangles are said to be similar .)
Yao was not good at math, but he believed that he cocould find someone to solve this problem. Wocould you help the great primary Ent Chinese emperor Yao?
InputThere are multiple test cases, and the number of test cases is no more than 12.
The first line of every test case is an integer n meaning that Hou Yi had shot the magic arrow for n times (2 <n <= 18 ).
Then n lines follow. Each line contains two integers X and Y (-100 <X, Y <100), the coordinate of a hole made by the magic arrow.
Please note that one hole can be the vertex of multiple triangles.
The input ends with n = 0.
OutputFor each test case, print a line with an integer indicating the maximum number of similar triangles Yao cocould get.
Sample Input
31 16 512 1040 01 12 01-10
 
Sample Output
14
 
Source2011 Asia Beijing Regional Contest

Question: give a maximum of 18 points and ask the maximum number of similar triangles.

Analysis: 18 points .. It is good to enumerate all triangles that can be made up to judge similarity .. Pay attention to the important and peaceful behavior situations ..

/*** @ Author neko01 * // # pragma comment (linker, "/STACK: 102400000,102400000") # include <cstdio> # include <cstring> # include <string. h> # include <iostream> # include <algorithm> # include <queue> # include <vector> # include <cmath> # include <set> # include <map> using namespace std; typedef long LL; # define min3 (a, B, c) min (a, min (B, c) # define max3 (a, B, c) max (, max (B, c) # define pb push_back # define mp (a, B) make_p Air (a, B) # define clr (a) memset (a, 0, sizeof a) # define clr1 (a) memset (a,-1, sizeof) # define dbg (a) printf ("% d \ n", a) typedef pair <int, int> pp; const double eps = 1e-8; const double pi = acos (-1.0); const int INF = 0x7fffffff; const LL inf = (LL) 1) <61) + 5; bool vis [250] [250]; struct point {double x, y; point (double x = 0, double y = 0): x (x), y (y) {}} a [22]; struct triangle {double x, y, z;} B [18*18*18]; bool gao (int I, int j) {if (Fabs (B [I]. x * B [j]. y-B [I]. y * B [j]. x) <eps & fabs (B [I]. z * B [j]. y-B [I]. y * B [j]. z) <eps) return true; return false;} bool check (int I, int j, int k) {point p1 = point (a [I]. x-a [j]. x, a [I]. y-a [j]. y); point p2 = point (a [k]. x-a [j]. x, a [k]. y-a [j]. y); return fabs (p1.x * p2.y-p1.y * p2.x) <eps;} double dis (int I, int j) {return sqrt (a [I]. x-a [j]. x) * (a [I]. x-a [j]. x) + (a [I]. y-a [j]. y) * (a [I]. y-a [j]. y);} int main () {int n, m; while (~ Scanf ("% d", & m) {clr (vis); n = 0; for (int I = 0; I <m; I ++) {int x, y; scanf ("% d", & x, & y); if (! Vis [x + 100] [y + 100]) {vis [x + 100] [y + 100] = true; a [n]. x = x; a [n ++]. y = y;} m = 0; for (int I = 0; I <n-2; I ++) {for (int j = I + 1; j <n-1; j ++) {for (int k = j + 1; k <n; k ++) {if (check (I, j, k) continue; double d1 = dis (I, j); double d2 = dis (I, k); double d3 = dis (j, k); double t [3]; t [0] = d1, t [1] = d2, t [2] = d3; sort (t, t + 3 ); if (t [0] + t [1] <= t [2]) continue; B [m]. x = t [0], B [m]. y = t [1]; B [m ++]. z = t [2] ;}}} int ans = 0; for (int I = 0; I <m; I ++ ){ Int sum = 1; for (int j = 0; j <m; j ++) if (I! = J & gao (I, j) sum ++; if (sum> ans) ans = sum;} printf ("% d \ n", ans );} return 0 ;}


Hdu4082 Hou Yi's secret brute force

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.