The first line of input contains an integer βTβ denoting the number of test cases.
The next βTβ lines represent the βTβ test cases.
The only line of each test case contains 4 integers denoting βNβ, βXβ, βYβ, and βZβ, where βNβ is the length of the rod and 'X', 'Y', 'Z' are the segments into which a given rod can be cut into.
For each test case, return the maximum number of cut segments from the given rod.
Print the output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= N <= 10000
1 <= X, Y, Z <= N
Time Limit: 1 sec
The key idea is that no maximum cuts that can be made in the rod of length βNβ depend upon Maximum cuts made in shorter length.For βnβ length rod ans depends upon 'Nβ - βXβ, βNβ - βYβ and βNβ - βZβ sizes of the rod.
Algorithm:
The key id is that no maximum cuts that can be made in the rod of length βNβ depend upon Maximum cuts made in shorter length. For βNβ length rod ans depends upon 'Nβ - βXβ, βNβ - βYβ and βNβ - βZβ sizes of the rod. Since it has overlapping subproblems it could be solved by dp.
Algorithm: