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

#define PI 3.14159265358979323846

int main(void)
{
    long long N;
    printf("点の数を入力してください: ");
    scanf("%lld", &N);

    long long count = 0;
    srand(time(NULL));

    for(long long i = 0; i < N; i++)
    {
        double x = (double)rand() / RAND_MAX;
        double y = (double)rand() / RAND_MAX;

        if(x*x + y*y <= 1.0)
            count++;
    }

    double pi = 4.0 * count / N;
    double error = fabs(pi - PI) / PI;

    printf("近似値: %.10f\n", pi);
    printf("誤差率: %.10f\n", error);

    return 0;
}