Problems > Coins of 1, 3 and 4

Coins of 1, 3 and 4

Difficulty: 1800 5000 ms 128 MB

dp

Using unlimited coins of denominations 1, 3 and 4, print the minimum number of coins summing to exactly N.

Input: one integer N.

Output: the minimum coin count.

Constraints:

  • 0 ≤ N ≤ 106

Sample Tests

Input 1
6
Output 1
2
Input 2
0
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.