Pagini recente » Cod sursa (job #928993) | Cod sursa (job #1405871) | Cod sursa (job #1987563) | Cod sursa (job #1830185) | Cod sursa (job #787196)
Cod sursa(job #787196)
#include <cstdio>
#define N 1000
#define k1 2437
#define k2 2137
using namespace std;
int a[N],b[N],c[N];
bool hash1[k1],hash2[k2];
int main() {
int n,m,i,j,x,y,key1,key2,groups = 0;
FILE *f = fopen("regiuni.in","r");
FILE *g = fopen("regiuni.out","w");
fscanf(f,"%d %d",&n,&m);
for(i = 0; i < n; i++)
fscanf(f,"%d %d %d",&a[i],&b[i],&c[i]);
for(i = 0; i < m; i++) {
fscanf(f,"%d %d",&x,&y);
key1 = 0, key2 = 0;
for(j = 0; j < n; j++) {
key1 += (((j+1)*((a[j]*x + b[j]*y + c[j] > 0) ? 1 : 0))<<1) % k1;
key2 += ((3*(j+1)*((a[j]*x + b[j]*y + c[j] > 0) ? 1 : 0))>>1) %k2;
}
if(!hash1[key1%k1] && !hash2[key2%k2]) {
hash1[key1%k1] = hash2[key2%k2] = true;
groups++;
}
}
fprintf(g,"%d",groups);
fclose(f);
fclose(g);
return 0;
}