We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
给定长度为n的数组,每个元素代表一个木头的长度,木头可以任意截断,从这堆木头中截出至少k个相同长度为m的木块。已知k,求max(m)。
ps: 截断的长度必须是整数
输入两行,第一行n, k,第二行为数组序列。输出最大值。
输入
5 5 4 7 2 10 5
输出
4
解释:如图,最多可以把它分成5段长度为4的木头
ps:数据保证有解,即结果至少是1。
The text was updated successfully, but these errors were encountered:
function CutWood(nums, m) { let count = 0; while (nums.length) { const num = nums.shift(); if (num >= m) { const rest = num - m; count++; rest && nums.push(rest); } } return count; } CutWood([4, 7, 2, 10, 5], 5)
Sorry, something went wrong.
No branches or pull requests
题目描述
给定长度为n的数组,每个元素代表一个木头的长度,木头可以任意截断,从这堆木头中截出至少k个相同长度为m的木块。已知k,求max(m)。
ps: 截断的长度必须是整数
输入两行,第一行n, k,第二行为数组序列。输出最大值。
输入
输出
解释:如图,最多可以把它分成5段长度为4的木头
ps:数据保证有解,即结果至少是1。
The text was updated successfully, but these errors were encountered: