#include<bits/stdc++.h>
using namespace std;
#define n 365
int main()
{
float p;
cin>>p;
float q=1;
int num=1;
while((1.0-q)<p)
{
float w=((n1.0)-(num1.0))/(n1.0);
q=qw;
num++;
}
cout<<num<<endl;
return 0;
}
Birthday p[aradox, which test case is not satisfied by this code
Your code is giving too much error. Either in copy and paste some variable names are changed by which I am not able to understand your logic.
You can see its correct code for the reference
#include<bits/stdc++.h>
using namespace std;
#define n 365
int main()
{
float p;
cin>>p;
float q=1;
int num=1;
while((1.0-q)<p)
{
float w=((n1.0)-(num1.0))/(n*1.0);
q=q *w;
num++;
}
cout<<num<<endl;
return 0;
}
Test case in which your code is failing
1
Correct ans is 366
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.