Magical box and spell

Magical box and spell

Time Limit: 3.0 s

Memory Limit: 256.0 MB

Description

One day Alice found a magical box and three spell \(a,b,c\) in a deep forest. Innitially the box has \(X\) gold coins inside it. He can do any of the following three operations any number of times.

  1. increase the number of gold coins by \(a\) coins
  2. increase the number of gold coins by \(b\) coins
  3. increase the number of gold coins by \(c\) coins

So it seems that Alice can have infinite amount of gold coins from the box. But there is a problem, the box is so heavy that Alice can not even bear the empty box by himself and he can collect gold coin from the box only once. Once he collects the coins from the box it will be vanished. He can bear maxumum \(N\) coins by himself. So alice wants to know that if he can use the spells in a way for a finite number of times to make exactly \(N\) coins from the box so that he can take home maximum amount of gold coins and no coin left over.
Also calculate the minimum number of operations he needs to do so.

Input

Only line of input takes 5 integers \(X,a,b,c,N\) : the innitial number of coins in the box, three spells and the number of gold coins Alice wants.

1 <= \(X\) <= 200
1 <= \(a,b,c\) <= 200
1 <= \(N\) <= 200

Output

Print a string "YES" if it is possible to get exactly \(N\) gold coins from the magical box or "NO" otherwise.
If the answer is "YES" then print an integer in the second line : the minimum number of operations to get exactly \(N\) coins

Sample

Input Output
1 1 3 2 10
YES
3

Innitially the box has 1 coin, Alice can use only the 2nd spell three times to gain more 9 coins and have a total of 10 coins.

Information

ID
1028
Difficulty
5
Category
(None)
Tags
(None)
# Submissions
23
Accepted
13
Accepted Ratio
57%
Uploaded By

Related

In following contests:

Brain booster #2