Cod sursa(job #253747)

Utilizator alexandru92alexandru alexandru92 Data 6 februarie 2009 12:04:36
Problema Grendizer Scor 0
Compilator cpp Status done
Runda Stelele Informaticii 2009, clasele 9-10, ziua 1 Marime 0.68 kb
#include<stdio.h>
#define InFile "grendizer.in"
#define OutFile "grendizer.out"
#define Nmax 100001 
struct
{
	long double x,y;
}pct[Nmax];
void abs(long double &x,long double &y)
{
	if(x<0) x=-x;
	if(y<0) y=-y;
}
int main()
{long double  n,m,x1,y1,x2,y2,r,mh;
 unsigned long i,j,nr;
FILE *f=freopen(InFile,"r",stdin),*g=freopen(OutFile,"w",stdout);
 scanf("%lf %lf",&n,&m);
 for(i=1;i<=n;i++) scanf("%lf %lf",&pct[i].x,&pct[i].y);
 for(i=1;i<=m;i++)
   {scanf("%lf %lf %lf",&x2,&y2,&r); nr=0;
    for(j=1;j<=n;j++)
	   {x1=pct[j].x-x2; y1=pct[j].y-y2; abs(x1,y1);
		 mh=x1+y1;
	    if(mh==r) nr++;
	   }
	printf("%ld\n",nr);
  }
 fclose(f); fclose(g);
 return 0;
}