Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Memory distribution Given a memory block of size N . You can divide the memory block in a way that fulfills the following two conditions:
Memory distribution
Given a memory block of size N You can divide the memory block in a way that fulfills the following two conditions:
After the division, each memory block should have lengths A Bor C
After the division, the number of memary blocks should be maximum
You are given integers N A B and C Print the maximuni possible number of memory blocks. It is guaranteed that at least one correct memory division exists,
Function description
Complete the function Memory This function takes the following parameters and returns the required answer
N: Represents the size of the block
A Represents the first valid division length
B: Represents the second valid division length
C: Represents the third valid division length
Input format for custom testing
Note: Use this Input format if you are testing against custom input or writing code in a language where we don\'t provide boilerplate code
The first line contains an integer N denoting the size of the memory block.
The second line contains an integer A denoting the first valid
division length.
The third line contains an integer B denoting the second valid
division length The fourth line contains an integer C denoting the third valid divesion length.
Output format
Print the maximum possible number of memory blocks. It is guaranteed that at least one correct memory division. exists.
Constraints
NABC
Sample input
Sample output
Explanation
You can divide the memory block in such a way. The first block has length and the second block has length The answer is
The following test cases are the actual test cases of this question that may be used to evaluate your submission
Sample input
Sample output
Sample input
Sample output
Note:
Your code must be able to print the sample output from the provided sample nout However your code is run against multiple hidden test cases Therefore. your code mast pass these hidden test cases to solve the problem statement
Umits
Time Unit sets for each input file Memory Limit MB Source Limit KB
Scoring
Score is assigned if any lestcase Destin Allowed Languages
CCM Coque Ca D Filing Fritlig Proovy. Haskell jave Node na Katip Lap SECLI. Le ObjectiveC OCam Cave Pescal Per Pip Python Pyon Panen Racket, Ruby Rust Save StypeScript Visual Rest
Code here :
def Memory N A BC;
# Write your code here
pass
N intinput
A intinput
B intinput
C intinput
out MemoryN A B C
print out
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started