#include <stdlib.h>
#include <stdio.h>
#include <math.h>
 
#define M_PI 3.14159265
 
int main() {
    double a, b, s, x1, x2, x3, x4, y1, y2, y3, y4;
    double r, q1, q2, q3, q4, shinchi;
    int count, m, n;
 
    // 理論的な円の面積
    shinchi = 1.0;
 
    // 円の中心
    x1 = 1.0; y1 = 0.0; // 第一の円の中心
    x2 = 0.0; y2 = 1.0; // 第二の円の中心
    x3 = 0.0; y3 = 0.0;
    x4 = 1.0; y4 = 1.0;
    r = 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; // 0.0 から 1.0 の乱数
            b = (double)rand() / RAND_MAX; // 0.0 から 1.0 の乱数
            // 距離の計算
            q1 = (a - x1) * (a - x1) + (b - y1) * (b - y1);
            q2 = (a - x2) * (a - x2) + (b - y2) * (b - y2);
            q3 = (a - x3) * (a - x3) + (b - y3) * (b - y3);
            q4 = (a - x4) * (a - x4) + (b - y4) * (b - y4);
            count++;
            // 両方の円の中に点が入っているかを確認
            if (q1 < r && q2 < r && q3 < r && q4 < r) s += 1.0;
        }
        s /= count; // 平均を取る
        printf("%d\t%f\n", n, fabs(s - shinchi)); // 理論値との差を表示
    }
 
    return 0;
}