Pagini recente » Cod sursa (job #1316536) | Cod sursa (job #444691) | Cod sursa (job #1744723) | Cod sursa (job #2346404) | Cod sursa (job #787190)
Cod sursa(job #787190)
#include <fstream>
#include <iostream>
#include <vector>
#define N 1000
#define k1 2437
#define k2 2137
using namespace std;
ifstream f("regiuni.in");
ofstream g("regiuni.out");
short a[N],b[N],c[N],hash1[k1],hash2[k2];
int main() {
int n,m,i,j,t,x,y,key1,key2,groups = 0;
f>>n>>m;
for(i = 0; i < n; i++)
f>>a[i]>>b[i]>>c[i];
for(i = 0; i < m; i++) {
f>>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] = 1;
groups++;
}
}
g<<groups;
return 0;
}