#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define M_PI 3.14159265

double true_area = 2.828;

int main() {
    double a, b, s, x1, x2, y1, y2, q1, q2;
    int count, m, n;

    x1 = 1.0; y1 = 0.0;
    x2 = 0.0; y2 = 1.0;
    count = 0;

    for (n = 10; n <= 100000; n = n * 5) {
        count = 0;
        s = 0.0;

        for (m = 0; m < n; m++) {
            a = (double)rand() / RAND_MAX;
            b = (double)rand() / RAND_MAX;

            q1 = (a - x1) * (a - x1) + (b - y1) * (b - y1);
            q2 = (a - x2) * (a - x2) + (b - y2) * (b - y2);
            
            if (q1 < 1.0 && q2 < 1.0) {
                s += 1.0;
            }
        }

        s /= n;
        printf("%d\t%f\n", n, fabs(s - true_area));
    }

    return 0;
}
