Question

A floor has n > 1 wooden planks, each of positive integer length. Any wooden plank...

A floor has n > 1 wooden planks, each of positive integer length. Any wooden plank is able to be cut into 3 or 5 equal length pieces. After n wooden planks are cut, we want all wooden planks to be the same integer length and as long as possible.

Given an array of wooden plank lengths, design an algorithm that calculates and returns the maximum length possible where all wooden planks have the same length. If this is not possible return -1.

Homework Answers

Answer #1

As all resultant pieces should be of same length and each plank wooden can be cut down in 3 or 5 equal pieces.

So we'll cut each plank in length 3 or 5 ,so each plank piece should be multiple of 3 or each plank piece should be multiple of 5.

int function(arr,n)//where arr shows length of each plank piece and n is no of elements.

{

int count1=0;

int count2=0;

int i=0;

while(i!=n)

{

count1=count1+(arr[i]/3); // no of pieces of length 3 of ith plank.

count2=count2+(arr[i]/5); // no of pieces of length 5 of ith plank.

i++;

}

if(count1==0 && count2==0)// if we couldn't cut any plank in length 3 or 5.

{

return -1;

}

else

{

return max(count1,count2);// max possible pieces.

}

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Show that, for any positive integer n, n lines ”in general position” (i.e. no two of...
Show that, for any positive integer n, n lines ”in general position” (i.e. no two of them are parallel, no three of them pass through the same point) in the plane R2 divide the plane into exactly n2+n+2 regions. (Hint: Use the fact that an nth line 2 will cut all n − 1 lines, and thereby create n new regions.)
Suppose that you want to add items to an array such that the items are always...
Suppose that you want to add items to an array such that the items are always ordered in ascending order; e.g., [1, 2, 2, 4, 5, 8, 9, 14, 32], and any duplicate values are adjacent to each other. We haven’t talked about sorting algorithms yet, so assume you want to be able to keep the items in the array in order without having to sort them. So for example, suppose you want to add the integer value 7 to...
There are N blocks, numbered from 0 to N-1, arranged in a row. A couple of...
There are N blocks, numbered from 0 to N-1, arranged in a row. A couple of frogs were sitting together on one block when they had a terrible quarrel. Now they want to jump away from one another so that the distance between them will be as large as possible. The distance between blocks numbered J and K, where JK, is computed as K-J+1. The frogs can only jump up, meaning that they can move from one block to another...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b,...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b, where a – b is equal to a given number. For example, consider the following array and suppose we want to find all pairs of integers a and b where a – b = 3 A = [10, 4, 6, 16, 1, 6, 12, 13] Then your method should return the following pairs: 4, 1 15, 12 13, 10 A poor solution: There are...
Multiple Choice Select the best answer from the available choices for each question. Which of the...
Multiple Choice Select the best answer from the available choices for each question. Which of the following is NOT part of the definition of a sample space S? S can be discrete or continuous Each outcome must be in S at most once Each element in S is equally likely Each outcome must be in S at least once S is a set of possible outcomes in an experiment Three A’s, three B’s, and two C’s are arranged at random...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
The Business Case for Agility “The battle is not always to the strongest, nor the race...
The Business Case for Agility “The battle is not always to the strongest, nor the race to the swiftest, but that’s the way to bet ’em!”  —C. Morgan Cofer In This Chapter This chapter discusses the business case for Agility, presenting six benefits for teams and the enterprise. It also describes a financial model that shows why incremental development works. Takeaways Agility is not just about the team. There are product-management, project-management, and technical issues beyond the team’s control. Lean-Agile provides...
In February 2012, the Pepsi Next product was launched into the US market. This case study...
In February 2012, the Pepsi Next product was launched into the US market. This case study provides students with an interesting insight into PepsiCo’s new product process and some of the challenging decisions that they faced along the way. Pepsi Next Case Study Introduction Pepsi Next was launched by PepsiCo into the US market in February 2012, and has since been rolled out to various international markets (for instance, it was launched in Australia in September 2012). The new product...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • The Huntington Boys and Girls Club is conducting a fundraiser by selling chili dinners to go....
    asked 3 minutes ago
  • 2. Please determinate the correctness of the following statements and justify your answers (preferably by examples)....
    asked 8 minutes ago
  • Explain the various methods of intelligence collection, specifically human intelligence and signals intelligence.
    asked 11 minutes ago
  • The provided file has syntax and/or logical errors. Determine the problem and fix the program. using...
    asked 14 minutes ago
  • What new items will you need to replace a failing processor? Select all that apply.   ...
    asked 33 minutes ago
  • A system is to be developed for an airport. When passengers have boarded an aircraft, a...
    asked 41 minutes ago
  • After reading Module 5 PowerPoint 1 - The Philosophy of Human Existance and Health Care Policy,...
    asked 49 minutes ago
  • 1. Do you feel play has a place in supporting literacy development in early childhood? Explain...
    asked 53 minutes ago
  • How should roles be selected for the Emergency Operations Center (EOC)?  Is seniority less important than experience?...
    asked 1 hour ago
  • Discuss routing issues and solutions namely, count-to-infinity, split horizon, split horizon with poison reverse, and hold-down...
    asked 1 hour ago
  • Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is〈5,10,3,12,5,50,6〉.
    asked 1 hour ago
  • Water at 60 F (density=62.4lbm/ft^3 and dynamic viscosity = 7.5x10^-4 lbm/ft-s) is to be pumped through...
    asked 1 hour ago