Pagini recente » Cod sursa (job #2127681) | Cod sursa (job #1572812) | Cod sursa (job #1309729) | Cod sursa (job #499716) | Cod sursa (job #44779)
Cod sursa(job #44779)
#include <stdio.h>
#define nmax 1005
#define mmax 1005
using namespace std;
int x1[mmax],y1[mmax],grup[mmax],n,m;
double a[nmax],b[nmax],c[nmax];
double px1[nmax],py1[nmax],px2[nmax],py2[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("%lf %lf %lf",&a[i],&b[i],&c[i]);
if(b[i] == 0) b[i] = 0.001;
px1[i] = 1; px2[i] = 2;
py1[i] = (double)(- c[i] - (double)a[i] * px1[i]) / b[i];
py2[i] = (double)(- c[i] - (double)a[i] * px2[i]) / b[i];
}
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(px1[i],py1[i],px2[i],py2[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;
}