Algorithm
Problem Statement for BirthdayOdds problem link- https://community.topcoder.com/stat?c=problem_statement&pm=1848&rd=4675 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
class BirthdayOdds {
public:
int minPeople(int minOdds, int DaysInYear) {
double comp = 100 - minOdds;
double all = 100;
for(int i = DaysInYear - 1; i >= 0; --i) {
if(all <= comp)
return DaysInYear - i;
all *= (1.0 * i / DaysInYear);
}
return DaysInYear + 1;
}
};
Copy The Code &
Try With Live Editor
Input
365
Output
Demonstration
TopCoder Solution SRM174-D1-250 Problem Statement for BirthdayOdds C,C++, Java, Js and Python ,SRM174-D1-250