All Submissions


Sanjoli Agarwal has recently been placed in Amazon and everyone is after her for chocolates and treats. So to cut short on her expenses she buys a big bar of Bournville of length N and decides to cut it into pieces of either length a, b, c or d in such a manner so that the number of pieces is maximised. (After cutting, only pieces of length a, b, c and d are allowed). Help her find the maximum number of pieces that she can get.

Input specifications:
The first line contains T: Number of test cases.
Each of the following T lines contains a single test case which has 5 numbers N, a, b, c, d.
The values of a, b, c and d may be same

Output specifications:
For each test case print the maximum number of pieces that can be obtained in a separate line.
if it is not possible to cut the bar print -1.

Constraints:
T <= 15
1 <= N, a, b, c, d <= 5000

Sample Input:
2
5 2 2 1 5
5 3 3 3 4

Sample Output
5
-1


Problem Setter : Shradha Chhaparia


Languages: Brain,C,C++,Java,Pascal,Perl,PHP,Python,Ruby,Text

Time Limit: 0.5 Second(s)
Score: 0 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0