subject
Computers and Technology, 10.05.2021 18:50 rome58

Witches Three witches are brewing potions around their cauldron when they notice that someone has mixed up all n of their carefully crafted potions. Each potion is a carefully-measured mixture of exact ratios of m distinct individual components (e. g. eye of newt, etc.). Mixed together, even though the components are the same, the ratios of the potions are now all wrong and will not have the desired effect.
Luckily, the vials in which the potions are kept are bottomless. In theory, the witches have an unbounded amount of each of the messed-up potions.
There is one potion in particular that the witches are interested in making so they need to combine the potions that they have into their cauldrons so as to come up with the correct ratio for it.
Consider the following example where n = 2 and m = 3: Two potions are available with the ratios of 1:2:3 and 3:7:1, respectively. By mixing those two solutions together in the ratio 1:2, it is possible to obtain a solution of the m = 3 components with ratio 7:16:5, but there is no way to combine these two potions together into a new one with ratio 3:4:5. However, if the witches find another potion with ratio 2:1:2 (making the problem into one where n = 3), then a 3:4:5 mixture is possible with eight parts of 1:2:3, one part 3:7:1, and 5 parts of 2:1:2.
So clearly, determining which mixtures can be obtained from a given set of potions is not trivial. It is your goal in this assignment to do so.
Input/Output
The top line of the input file (input. txt) will be a line with a desired ratio in the form a1 : a2 : a3 : ... : am. The next n lines will be the base solution ratios.
Your output file (output. txt) will consists of n lines, each containing a single integer. These will indicate the parts necessary to get the desired ratio. If no combination is possible, then return the value −1 on each line.
1
So, for example above, the input file (input. txt) would look as follows:
3:4:5
1:2:3
3:7:1
2:1:2
and the output file (output. txt) would look as follows:
8
1
5
the program can be written in either python, c++ or java

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:00
To check whether your writing is clear , you can
Answers: 2
question
Computers and Technology, 23.06.2019 21:00
Which set of steps will organize the data to only show foods with more than 100 calories and rank their sugar content from greatest to least?
Answers: 1
question
Computers and Technology, 24.06.2019 22:10
How many different ways are there to order the eight jobs in the queue so that job usu comes somewhere before cdp in the queue (although not necessarily immediately before) and cdp comes somewhere before bbd (again, not necessarily immediately before)?
Answers: 1
question
Computers and Technology, 25.06.2019 18:30
If you like to spend time outdoors working with plants and animals, you have a(n) a. bodily/kinesthetic learning style b. intrapersonal learning style c. visual/spatial learning style d. naturalistic learning style
Answers: 1
You know the right answer?
Witches Three witches are brewing potions around their cauldron when they notice that someone has...
Questions
question
English, 12.09.2021 06:10
question
Mathematics, 12.09.2021 06:10
question
Social Studies, 12.09.2021 06:10
question
Computers and Technology, 12.09.2021 06:10
question
English, 12.09.2021 06:20
question
Social Studies, 12.09.2021 06:20
question
Social Studies, 12.09.2021 06:20
question
Biology, 12.09.2021 06:20
Questions on the website: 13722360