Uva270 lining up search?

Source: Internet
Author: User

Enumerate all two points and add the third point to determine whether the three points are collocated.

Ga soeasy!

# Include <iostream> # include <cstring> # include <string> # include <cstdio> # include <cmath> # include <algorithm> # include <vector> # include <map> # define INF 0x3f3f3fusing namespace STD; struct point {int X, Y;} p [705]; bool CMP (point a, point B) {return. x <B. x;} int main () {int I, TMP, ANS, j, k, n, K1, K2, K3, K4; while (scanf ("% d ", & N) {for (I = 0; I <n; I ++) scanf ("% d", & P [I]. x, & P [I]. y); sort (p, p + N, CMP); ans = 1; // 1 for (I = 0; I <n; I ++) {for (j = I + 1; j <n; j ++) {TMP = 2; k1 = P [J]. x-P [I]. x; k2 = P [J]. y-P [I]. y; For (k = J + 1; k <n; k ++) {K3 = P [K]. x-P [J]. x; K4 = P [K]. y-P [J]. y; If (K1 * K4 = k2 * K3) {TMP ++; // printf ("% d \ n", I, j, k) ;}} if (TMP> ans) ans = TMP ;}} printf ("% d \ n", ANS) ;}return 0 ;}

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.