Problem Link
Problem Type : Geometry, Circle.
Difficulty Level : Easy
Author : Imdad
Here, is the c++ implementation of this problem.
Problem Type : Geometry, Circle.
Difficulty Level : Easy
Author : Imdad
Here, is the c++ implementation of this problem.
#include <iostream> #include <cmath> #include <cstdio> using namespace std; double dist(double x, double y, double x1, double y1){ return sqrt((x-x1)*(x-x1) + (y-y1)*(y-y1)); } bool is_striped(double x, double y, double k){ if(dist(0,0, x,y) > k) return false; if(dist(0,k, x,y) > k) return false; if(dist(k,0, x,y) > k) return false; if(dist(k,k, x,y) > k) return false; return true; } int main(){ int n,i,k,m; double x,y; while(scanf("%d %d", &n, &k) && n){ m = 0; for(i = 0; i < n; i++){ scanf("%lf %lf", &x, &y); if(is_striped(x, y, k*1.)) m++; } printf("%.5lf\n", (m*k*k*1.) / n ); } return 0; }
No comments:
Post a Comment