Page 4 of 4
Re: 10589 - Area
Posted: Tue Jan 14, 2014 11:14 pm
by hoimo
@ brianfry713, plz help.
i am getting WA in this problem.
but i cant find my problem.
thanx in advance.
Re: 10589 - Area
Posted: Wed Jan 15, 2014 11:59 pm
by brianfry713
Try solving it without using floating point.
Re: 10589 - Area
Posted: Fri Jan 17, 2014 9:38 pm
by hoimo
many many thnx & sorry 4 my late rply.

Re: 10589 - Area
Posted: Mon Jul 13, 2015 4:48 pm
by nada_elnokaly
I need help please ,getting so many WA's and can't understand why !!
Code: Select all
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll shift=1e7;
struct point{
ll x,y;
point(){}
point(ll x,ll y):x(x),y(y){}
};
ll dist(point a,point b){
ll x=abs(a.x-b.x);
ll y=abs(a.y-b.y);
return x*x+y*y;
}
int len(ll x){
if(!x)return 1;
int ret=0;
while(x)x/=10,ret++;
return ret;
}
int main(){
ll N,a;
while(true){
cin>>N>>a;
a*=shift;
if(!N)return 0;
ll M=0;
point temp;
for(int i=0;i<N;i++){
double d1,d2;
cin>>d1>>d2;
temp.x=(ll)(d1*shift);
temp.y=(ll)(d2*shift);
ll dist1=dist(point(0,0),temp);
ll dist2=dist(point(0,a),temp);
ll dist3=dist(point(a,0),temp);
ll dist4=dist(point(a,a),temp);
ll D=a*a;
if(dist1<=D && dist2<=D && dist3<=D && dist4<=D )M++;
}
ll A = M * a/shift * a/shift;
printf("%lld.",A/N);
int dec=0;
ll res2=A%N;
int len1=len(N)-1;
int len2=len(res2);
for(int i=0;i<len1-len2;i++)printf("0"),dec++;
printf("%lld",A%N),dec+=len(A%N);
for(int i=0;i<5-dec;i++)printf("0");
printf("\n");
}
return 0;
}