Pagini recente » Cod sursa (job #161999) | Cod sursa (job #1905113) | Cod sursa (job #230251) | Cod sursa (job #345524) | Cod sursa (job #44788)
Cod sursa(job #44788)
#include <stdio.h>
#define nmax 1005
#define mmax 1005
using namespace std;
int x1[mmax],y1[mmax],grup[mmax],n,m;
int a[nmax],c[nmax];
double b[nmax];
double cp(double x1,double y1,double x2,double y2,double x3,double y3) {
return (double)(x2 - x1) * (y3 - y2) - (x3 - x2) * (y2 - y1);
}
int main() {
freopen("regiuni.in","r",stdin);
freopen("regiuni.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i = 1; i <= n; i++) {
scanf("%d %lf %d",&a[i],&b[i],&c[i]);
if(b[i] == 0) b[i] = 0.001;
}
for(int i = 1; i <= m; i++) {
scanf("%d%d",&x1[i],&y1[i]);
grup[i] = 1;
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) {
double o = cp(1,(double)(- c[i] - a[i]) / b[i],2,(double)(- c[i] - 2 * a[i]) / b[i],x1[j],y1[j]);
grup[j] *= 2;
if(o > 0) grup[j]++;
}
int r = 0;
for(int i = 1; i <= m; i++) {
int ok = 1;
for(int j = 1; j < i; j++) if(grup[i] == grup[j]) ok = 0;
if(ok) r++;
}
printf("%d\n",r);
return 0;
}