class Solution {
public:
bool choose(vector<int> doors, int id) {
return (doors[id] == 1);
}
bool newChoose(vector<int> newDoors) {
int i = 0;
if (newDoors[i] == -1)i++;
return (newDoors[i] == 1);
}
};
int test1() {
Solution sol = Solution();
vector<int> doors1{1, 0, 0};
vector<int> doors2{0, 1, 0};
vector<int> doors3{0, 0, 1};
int cnt = 0;
if (sol.choose(doors1, 1)) cnt++;
if (sol.choose(doors2, 1)) cnt++;
if (sol.choose(doors3, 1)) cnt++;
printf("P1=%lf\n", cnt / 3.0);
cnt = 0;
vector<int> newDoors1_1{1, 0, -1};
vector<int> newDoors1_2{1, -1, 0};
vector<int> newDoors2_1{-1, 1, 0};
vector<int> newDoors2_2{0, 1, -1};
vector<int> newDoors3_1{-1, 0, 1};
vector<int> newDoors3_2{0, -1, 1};
if (sol.newChoose(newDoors1_1)) cnt++;
if (sol.newChoose(newDoors1_2)) cnt++;
if (sol.newChoose(newDoors2_1)) cnt++;
if (sol.newChoose(newDoors2_2)) cnt++;
if (sol.newChoose(newDoors3_1)) cnt++;
if (sol.newChoose(newDoors3_2)) cnt++;
printf("P2=%lf\n", cnt / 6.0);
}
int main() {
srand((unsigned) time(NULL));
int N = 1e7, cnt = 0, R = 1e6;
for (int i = 0; i < N; i++) {
double a = (1.0 * rand() / RAND_MAX);
double b = (1.0 * rand() / RAND_MAX);
if (a * a + b * b < 1.0) cnt++;
}
printf("%lf", (4.0 * cnt) / N);
return 0;
}
int lower_bound(vector<int>&arr,int target){
int n=arr.size();
if(n==0){
return -1;
}
int l=0,r=arr.size()-1;
while(l<r){
int mid=l+((r-l)>>1);
if(arr[mid]==target && arr[mid-1]!=target && mid-1>=0) return mid;
if(arr[mid]>=target)r=mid;
else l=mid+1;
}
if(arr[l]==target)
return l;
return -1;
}