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)