A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d2/d7d/egg__dropping__puzzle_8cpp_source.html below:

TheAlgorithms/C++: dynamic_programming/egg_dropping_puzzle.cpp Source File

11int

eggDrop(

int

n,

int

k) {

12

std::vector<std::vector<int> > eggFloor(n + 1, std::vector<int>(k + 1));

16 for

(

int

i = 1; i <= n; i++) {

22 for

(

int

j = 1; j <=

k

; j++) {

26 for

(

int

i = 2; i <= n; i++) {

27 for

(

int

j = 2; j <=

k

; j++) {

28

eggFloor[i][j] = INT_MAX;

29 for

(

int

x = 1; x <= j; x++) {

32 result

= 1 + max(eggFloor[i - 1][x - 1], eggFloor[i][j - x]);

33 if

(result < eggFloor[i][j])

39 return

eggFloor[n][

k

];

44

cout <<

"Enter number of eggs and floors: "

;

46

cout <<

"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