@ brianfry713, plz help.
i am getting WA in this problem.
but i cant find my problem.
thanx in advance.
10589 - Area
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10589 - Area
Try solving it without using floating point.
Check input and AC output for thousands of problems on uDebug!
Re: 10589 - Area
many many thnx & sorry 4 my late rply.


-
- New poster
- Posts: 3
- Joined: Thu Oct 23, 2014 12:29 am
Re: 10589 - Area
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;
}