>>403
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main()
{
double x, y, pai;
int i, n, in = 0;

srand(time(NULL));

cout << "繰り返し回数 N = ";
cin >> n;

for (i = 0; i < n; i++) {
x = rand() / (RAND_MAX + 0.1);
y = rand() / (RAND_MAX + 0.1);
if (x * x + y * y <= 1.0)
in++;
}
pai = 4.0 * in / n;

cout << "繰り返し回数 N = " << n << '\n';
cout << "モンテカルロ法によるπ = " << pai << endl;
}