#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <time.h>
#define PI 3.1415

double D(double x1,double y1,double x2,double y2)
//二点間の距離を求める　(x1,y1) (x2,y2)
{
  double i=0;
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));//三平方の定理
}

main()
{
  int count=0;
  int i,x,c1,c2;
  srand((unsigned)time(NULL));
  for(i=0;i<100000;i++){ //100000回試してみる
    x=rand();
    c1=rand();
    c2=rand(); //ランダムに座標を設定
    if(x<c1) count++; //条件1
    if((0<x<c1) & (D(x/2,0,c1,c2)<(x/2)))
        count++ ;//条件2
    }
  printf("確率は%f%%\n",((double)count/100000)*100);
  printf("理論値%f%%\n",100*3/(8-(6*sqrt(3)/PI)));
}
