Why my code giving one answer wrong?
#include<bits/stdc++.h>
using namespace std;
int main() {
float p;
cin>>p;
float x=1.0;
int people=0;
float num=365;
float denom=365;
if(p==1)
{
cout<<366;
return 0;
}
while(x>1-p)
{
x=x*(num)/denom;
num--;
people++;
}
cout<<people;
return 0;
}
Do it like this
This is giving me TLE.
Check now ->
1 Like
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.