Codeforces Round #284 (Div. 2) Problem solving report on C (Computational geometry)

Source: Internet
Author: User

Title Address

Brief test Instructions:

Given the coordinates of two points, and a, B, C of some general linear equation ax+b+c=0, these straight lines act as streets, seeking from one point to another the number of streets to cross. (Not in the street at two o ' All)

Thinking Analysis:

The street from one point to the other must span the equivalent of 2.1 points on one side of the line and the other on the other side. Only need to take two point coordinates in, a positive one minus. These lines are checked sequentially, and the sum is counted.

  

1#include <stdio.h>2#include <bits/stdc++.h>3#include <iostream>4 using namespacestd;5typedefLong Longll;6 intMain ()7 {8ll x1,x2,y1,y2,n,a,b,c,s,q,ans=0;9scanf"%i64d%i64d",&x1,&y1);Tenscanf"%i64d%i64d",&x2,&y2); Onescanf"%i64d",&n); A      while(n--) -     { -scanf"%i64d%i64d%i64d",&a,&b,&c); thes=a*x1+b*y1+C; -q=a*x2+b*y2+C; -         if((s>0&&q<0)|| (s<0&&q>0)) -ans++; +     } -printf"%i64d\n", ans); +     return 0; A}

Codeforces Round #284 (Div. 2) Problem solving report on C (Computational geometry)

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.