A friend just askedAlgorithmThe problem is as follows:
There are a pile of wood rods with a length between 1 m and 21 m (the length is an integer). The user-defined wood rod length is also the number of custom wood rods.
One group of sample data is 300 of 10 m wooden sticks, 223 of 14 m wooden sticks, 412 of 18 m wooden sticks, and 301 of 2 m wooden sticks, 5-meter wooden stick with 48
What I want is, how many 21-meter-long wooden sticks can these wooden sticks make up? (Wood sticks cannot be cut, but can be spliced ).
This is a typical algorithm problem. It is similar to the data structure of the C language version in the current year and the one in the algorithm: How many rooster, hen, and chicken are bought in RMB (their prices are different ), how many solutions are available.
The simplest solution to this type of problem is the exhaustive method. You can try to write its C #, Java, C, and PHP algorithms, or use other algorithms to solve the problem, we look forward to your participation. Thank you.