PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000066. Có bao nhiêu cách đổi tiền? (Let Me Count The Ways)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Có bao nhiêu cách đổi tiền? (Let Me Count The Ways)

Let Me Count The Ways

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

After shopping, someone receives 1717 cents in change. On one occasion the change consists of a 1010-cent coin, a 55-cent coin, and two pennies; on another occasion it consists of two 55-cent coins and seven pennies. These are different combinations of coins with the same total value. The task is to count all distinct combinations for any given amount.

This problem uses the five standard US coin denominations 11, 55, 1010, 2525, and 5050 cents. There are unlimited quantities of every denomination. Two combinations differ only if the number of coins of at least one denomination differs; the order in which coins are given does not distinguish combinations.

Given a nonnegative amount nn in cents, compute the exact number of combinations that produce nn, including n=0n=0 (which has one empty combination). Do not take the count modulo any number. The result may exceed the range of a signed 3232-bit integer.

Instead of printing only the count, you must output one of two exact English sentences. One sentence is used when there is exactly one combination, and the other is used when there are multiple combinations.

Input

One line contains an integer nn, the target amount in cents.

Output

If exactly one combination exists, print exactly: There is only 1 way to produce n cents change. with n replaced by the input value.

If there are m>1m>1 combinations, print exactly: There are m ways to produce n cents change. with m and n replaced by their values. Preserve capitalization, spacing, and the final period.

Subtasks

  • Subtask 1 (20 points): 0≤n≤1000\le n\le100; unlimited coins of denominations 11, 55, 1010, 2525, 5050 cents.

  • Subtask 2 (30 points): 0≤n≤30000\le n\le3000; unlimited coins of denominations 11, 55, 1010, 2525, 5050 cents.

  • Subtask 3 (50 points): 0≤n≤300000\le n\le30000; unlimited coins of denominations 11, 55, 1010, 2525, 5050 cents.

Examples

Input

17

Output

There are 6 ways to produce 17 cents change.

Explanation

For n=17n=17, denominations 2525 and 5050 cannot be used. Without a 1010-cent coin, one may use 00, 11, 22, or 33 nickels, with the rest made up by pennies, giving four combinations. With one 1010-cent coin, one may use 00 or 11 nickel, giving two additional combinations. Thus there are 4+2=64+2=6 combinations and the plural sentence is required. At n=4n=4, there is only one combination, four pennies, so the singular sentence is used.