Bhanu's Subway Party
Practice
2.5 (2 votes)
Medium
Problem
28% Success 175 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Bhanu Bhai and his friends bought a giant subway of length "n". Bhanu is assigned a duty of cutting the sub in as many pieces as possible. But his friends gave him condition that  each piece should be either of length x, y or z. Since Bhanu is busy eating a pizza, he assigns you a task to maximise number of pieces.

 

Input

  • First line contains T, number of test cases.
  • First line of each test case contains n, the length of the subway.
  • Second line of each test case contains x, y and z respectively.

Output

  • Print maximum number of subs into which the entire giant sub can be divided in, on a new line.

Constraints

  • 1 <= t <= 70
  • 1 <= n, x, y, z <= 4000
     

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
5 votes
Tags:
Ad-HocAlgorithmsMediumDynamic ProgrammingDynamic programming
Points:30
2 votes
Tags:
Binary search algorithmDynamic ProgrammingMediumAlgorithmsDepth-first searchDynamic programmingDisjoint set
Points:30
15 votes
Tags:
Applications of Dynamic ProgrammingAlgorithmsDynamic ProgrammingDynamic programming