QOJ.ac

QOJ

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

#57. Egyptian Fraction

Statistics

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

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.