"POJ 3668" Game of Lines

Source: Internet
Author: User

Game of Lines
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 6555 Accepted: 2439

Description

Farmer John had challenged Bessie to the following GAME:FJ have a board with dots marked at N (2≤ n ≤2 XX) distinct lattice points. Dot i has the integer coordinates XI and Yi ( -1,000≤ xi ≤ 1,000; -1,000≤ yi ≤1,000).

Bessie can score a point in the game by picking, the dots and drawing a straight line between them; However, she was not allowed to draw a line if she had already drawn another line. Bessie would like to know hers chances of winning, so she had asked you to help find the maximum score she can obtain.

Input

* Line 1: A single integer: N
* Lines 2. N+1:line i+1 describes lattice point i with the space-separated integers: Xi and Yi.

Output

* Line 1: A single integer representing the maximal number of lines Bessie can draw, No. of which is parallel.
 

Sample Input

4-1 1-2 00) 01 1

Sample Output

4

Source

Usaco February Silver However, the problem is just a simple enumeration. Enumerates a point and another point match, and records the slope of the line, ignoring if any slope has been found. Note: Since the line may be parallel to the y-axis (that is, x[i] = = X[j]), this is set to infinity (however just 231-1).
#include <cstdio>#include<cstring>#include<Set>using namespacestd;intx[205];inty[205];intN;Set<Double>s;intMain () {scanf ("%d", &N);  for(inti =0; I < n; ++i) scanf ("%d%d", &x[i], &Y[i]); intAns =0;    S.clear ();  for(inti =0; I < n; ++i) for(intj = i +1; J < N; ++j) {DoubleK; if(X[i]-x[j] = =0) K =0x7fffffff; ElseK = (Double) (Y[i]-y[j])/(X[i]-X[j]); if(!S.count (k)) {                ++ans;            S.insert (k); }} printf ("%d\n", ans); return 0;}

"POJ 3668" Game of Lines

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.