Showing wrong answer in second test case

#include
using namespace std;

int main() {
float p;
cin>>p;
float prob=0.0;
float den=365;
float num=365;
float a=1.0;
int ans=0;
while(prob<p)
{
a=((num*1.0)/den)*a;
prob=1-a;
num–;
ans++;
}
cout<<ans;
return 0;
}

Your approach seems to be heading in a wrong direction, do some maths on pen and paper and you will get your answer. Also do take care of the condition if p = 1. Since you are given p, you can easily find the minimum number of people using maths.

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.