| 2 | using namespace std; |
| 3 | |
| 4 | int main() { |
| 5 | int N = 10000; // N �͎��s�i�K�X�ύX����j |
| 6 | int M = 0; |
| 7 | for (int i = 1; i <= N; i++) { |
| 8 | double px = rand() / (double)RAND_MAX; // 0 �ȏ� 1 �ȉ��̗����i�����_���Ȑ��j�� |
| 9 | double py = rand() / (double)RAND_MAX; // 0 �ȏ� 1 �ȉ��̗����i�����_���Ȑ��j�� |
| 10 | // ���_����̋����� sqrt(px * px + py * py) |
| 11 | // ���ꂪ 1 �ȉ��ł���Ηǂ��̂ŁA�����́upx * px + py * py <= 1�v |
| 12 | if (px * px + py * py <= 1.0) M += 1; |
| 13 | } |
| 14 | printf("%.12lf\n", 4.0 * M / N); |
| 15 | return 0; |
| 16 | } |
nothing calls this directly
no outgoing calls
no test coverage detected