# Bzoj_1610_[usaco2008_feb]_line Wired Game _ (Computational Geometry Basics + violence)

Source: Internet
Author: User

Describe

http://www.lydsy.com/JudgeOnline/problem.php?id=1610

Given n points, ask 22 the number of lines in the determined line, the slope of a different total.

Analysis

The brute force enumerates the lines, calculates the slope in the K array (the slope does not exist as an INF), and then goes to the number of heavy statistics.

In fact, special water ...

`1#include <bits/stdc++.h>2 using namespacestd;3 4 Const intmaxn= \$+5;5 Const Doubleeps=1e-8, inf=0x7fffffff;6 intn,cnt;7 Doublek[(MAXN*MAXN) >>1];8 9 structpt{Ten     Doublex, y; OnePtDoublex=0,Doubley=0): X (x), Y (y) {} A }P[MAXN]; - intDCMP (Doublex) {if(Fabs (x) <eps)return 0;returnx<0?-1:1; } - DoubleGETK (pt a,pt b) { the     if(dcmp (a.x-b.x) = =0)returnINF; -     return(A.Y-B.Y)/(a.x-b.x); - } - intMain () { +scanf"%d",&n); -      for(intI=1; i<=n;i++) scanf ("%LF%LF",&p[i].x,&p[i].y); +      for(intI=1; i<=n;i++) A          for(intj=i+1; j<=n;j++) atk[++cnt]=GETK (P[i],p[j]); -Sort (k +1, k+cnt+1); -     intans=0; -      for(intI=1; i<=cnt;i++)if(k[i]!=k[i-1]) ans++; -printf"%d\n", ans); -     return 0; in}`
View Code

P.S.

1. You can also use unique to weight. Note to sort first.

1610: [Usaco2008 feb]line tethered game time limit:5 Sec Memory limit:64 MB
submit:1810 solved:815
[Submit] [Status] [Discuss] Description

Farmer John has recently invented a game to test the pretentious Bessie. At the beginning of the game, FJ would give Bessie a piece of wood with a non-coincident point of N (2 <= n <= 200), where the horizontal and vertical coordinates of the point I were x_i and y_i ( -1,000 <= x_i <=1,000; -1,000 <= y_i <= 1,000). Bessie could choose two dots to draw a straight line over them, and only if there were no straight lines parallel to the drawing line in the plane. At the end of the game Bessie's score was the total number of lines she had drawn. In order to win in the game, Bessie found you and wanted you to help her calculate the maximum possible score.

Input

* Line 1th: Enter 1 positive integers: N

* 2nd. N+1 Line: Line i+1 with 2 spaces separated by the integer x_i, y_i, describes the coordinates of point I

Output

Line 1th: Output 1 integers, indicating the maximum score for Bessie, the number of straight lines that she can draw in parallel to each other

Sample Input4
-1 1
-2 0
0 0
1 1
Sample Output* Line 1th: Output 1 integers, indicating the maximum score for Bessie, the number of lines that she can draw in parallel to each other

HINT

4 Output Description: Bessie can draw the following 4 lines of slope: -1,0,1/3 and 1.

Source

Silver

Bzoj_1610_[usaco2008_feb]_line Wired Game _ (Computational Geometry Basics + violence)

Related Keywords:

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.