QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100 Hackable ✓

#57. Egyptian Fraction

统计

This task is based on The 1997 British Informatics Olympiad

When ancient Egyptians wrote fractions they were only able to use ones of the form $\frac{1}{a}$, called unit fractions. An Egyptian wanting to write the fraction $\frac{b}{c}$, where $b$ was not $1$, had to write it as the sum of (different) unit fractions. All fractions $\frac{b}{c}$ ($b < c$) can be written as an Egyptian fraction.

For example, the fraction $\frac{5}{6}$ was written as $\frac{1}{2} + \frac{1}{3}$, and $\frac{6}{7}$ was written as $\frac{1}{2} + \frac{1}{3} + \frac{1}{42}$. Egyptian fractions are not necessarily unique: $\frac{6}{7}$ can also be written as $\frac{1}{2} + \frac{1}{4} + \frac{1}{14} + \frac{1}{28}$. Since the unit fractions must be different, $\frac{2}{3}$ can be written as $\frac{1}{2} + \frac{1}{6}$, but not $\frac{1}{3} + \frac{1}{3}$.

An Egyptian fraction representing $\frac{b}{c}$ is minimal if it uses the smallest number of unit fractions possible. An Egyptian fraction is optimal if it is minimal, and the smallest unit fraction is as large as possible. There may be several minimal and several optimal Egyptian fractions for a given $\frac{b}{c}$.

For example $\frac{19}{45}$ cannot be represented as the sum of two unit fractions, but there are $5$ ways of representing it as the sum of 3 unit fractions:

  • $1/3 + 1/12 + 1/180$,
  • $1/3 + 1/15 + 1/45$,
  • $1/3 + 1/18 + 1/30$,
  • $1/4 + 1/6 + 1/180$, and
  • $1/5 + 1/6 + 1/18$.

These five Egyptian fractions are all minimal. Only $\frac{1}{5} + \frac{1}{6} + \frac{1}{18}$ is optimal, since $\frac{1}{18}$ is larger than $\frac{1}{30}$, $\frac{1}{45}$ and $\frac{1}{180}$.

Given two integers $b$ and $c$, find any optimal Egyptian fraction representing $\frac{b}{c}$.

Input

The first line of the input contains two integers $b$ and $c$ ($1 \leq b < c \leq 1\,000$).

Output

The first line of the output contains a single integer $t$, indicating the number of the Egyptian fraction you used.

The next line of the output contains $t$ integers $a_1, a_2, \cdots, a_t$.

If there are multiple optimal plans, you may print any of them.

Example

Input

19 45

Output

3
5 6 18
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.