VM7WC '16 #5 Silver - Jayden Eats Chocolate

View as PDF

Submit solution


Points: 5
Time limit: 1.0s
Memory limit: 64M
Author:

Problem type

Jayden is a little kid that likes to eat chocolate. The enjoyment that he gets from eating chocolate increases exponentially depending on how many people eat it with him. Jayden has an infinite number of friends and he would like to share his chocolate with as many of his friends as possible.

The only thing that is more fun than eating chocolate is playing a game. The chocolate bar that he currently has is a 1 by N line of chocolate squares, and he decides to break up the entire bar into pieces of either X, Y, or Z consecutive squares to make this problem interesting, giving one piece to each friend. What is the highest number of friends that receive a piece of chocolate following these rules?

Input Specification

On the first line will be the positive integer N (1 \leq N \leq 10^5). The next line will contain the integers X, Y, and Z, (1 \leq X, Y, Z \leq N). X, Y, and Z may share the same value.

Output Specification

On a single line, print the highest number of friends that can receive a piece of chocolate of X, Y, or Z squares. There will always be a valid answer.

Sample Input

13
3 9 4

Sample Output

4

Comments


  • 2
    1419903188  commented on Aug. 11, 2018, 5:48 a.m.

    Friends

    I wish I had an infinite number of friends, too. owo


  • -12
    haoda  commented on Oct. 1, 2016, 10:37 a.m. edited
    00

    00