Poj 1118 and 2606 (water question)

Source: Internet
Author: User

[Description]: the two questions are about the number of points in a straight line.

[Analysis]: brute force and equal slope are used to solve the problem. However, when calculating the slope, division should be avoided, and all operations should be conducted by transposition multiplication. Otherwise, re will be performed.

Take "2606" as an example to paste code. "1118" only indicates that the array size is different, and the other values are the same.

// 216 K 0 Ms # include <iostream> using namespace STD; int A [205], B [205]; int main () {int t; CIN> T; int res; int ans = 0; For (INT I = 0; I <t; I ++) {CIN> A [I]> B [I];} for (INT I = 0; I <T-2; I ++) {for (Int J = I + 1; j <T-1; j ++) {res = 0; for (int K = J + 1; k <T; k ++) {If (B [J]-B [I]) * (a [k]-A [J]) = (a [J]-A [I]) * (B [k]-B [J]) res ++; If (RES> ans) ans = res ;}} cout <ans + 2 <Endl; return 0 ;}


Poj 1118 and 2606 (water question)

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.