#include <bits/stdc++.h>
using namespace std;
#define LL long long
int Maxd;
LL Ans[10], now[10];
bool flag;
inline void chkmin()
{
for(int i = Maxd; i; i--)
if(now[i] < Ans[i])
{
for(int i = 1; i <= Maxd; i++) Ans[i] = now[i];
return;
}
else if(now[i] > Ans[i]) return;
}
inline void id_dfs(LL a, LL b, int k) //a / b
{
LL Gcd = __gcd(a, b);
a /= Gcd, b /= Gcd;
if(k == Maxd)
{
if(b%a == 0)
{
now[k] = b/a;
chkmin();
flag = 1;
}
return;
}
for(LL i = max(now[k-1], b/a) + 1; a*i < b*(Maxd-k+1); i++) //注意上下界
now[k] = i, id_dfs(a*i-b, b*i, k+1);
}
int main()
{
LL a, b;
memset(Ans, 0x7f, sizeof Ans);
scanf("%lld%lld", &a, &b);
for(Maxd = 1; ; Maxd++)
{
id_dfs(a, b, 1);
if(flag)
{
for(int i = 1; i <= Maxd; i++)
printf("%lld%c", Ans[i], i == Maxd ? 10 : 32);
return 0;
}
}
}
注意题目要求,最小的分数最大,即最大的分母最小