eggDrop(
intn,
intk) {
12std::vector<std::vector<int> > eggFloor(n + 1, std::vector<int>(k + 1));
16 for(
inti = 1; i <= n; i++) {
22 for(
intj = 1; j <=
k; j++) {
26 for(
inti = 2; i <= n; i++) {
27 for(
intj = 2; j <=
k; j++) {
28eggFloor[i][j] = INT_MAX;
29 for(
intx = 1; x <= j; x++) {
32 result= 1 + max(eggFloor[i - 1][x - 1], eggFloor[i][j - x]);
33 if(result < eggFloor[i][j])
39 returneggFloor[n][
k];
44cout <<
"Enter number of eggs and floors: ";
46cout <<
"Minimum number of trials in worst case: "<< eggDrop(n, k) <<
endl;
double k(double x)
Another test function.
uint64_t result(uint64_t n)
int main()
Main function.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4