Birthday Paradox

#include
using namespace std;
int main() {
float x=1.0;
int people=0;
float num=365;
float denom=365;
float p;
cin>>p;
if(p==1.0){
cout<<“366”<<endl;
}
while(x>1-p){
x=x*(num/denom);
num–;
people++;
}
cout<<people<<endl;
return 0;
}

Im failing with one testcase please help me with that. error:WRONG ANSWER

hello @bhanu_0108

use return 0 inside this if statement, otherwise reamaing other statements written below it will also execute

#include using namespace std; int main(){ float x=1.0; int people=0; float nume=365; float denom=365; float p; cin>>p; if(p==1.0){ cout<<366<<endl; return 0; } while(x>=1-p){ x=x*(nume)/denom; nume–; people++; } cout<<people<<endl; }

thank you Sir… done succesfully submitted.

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.