#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_VALUE = 1000; // Đặt giá trị khởi tạo lớn cụ thể cho minCount
int minCount = MAX_VALUE;
vector<int> bestSolution;
void backtrack(int M, int N, vector<int>& solution, int start) {
// Dừng khi tử số về 0
if (M == 0) {
if (solution.size() < minCount) {
minCount = solution.size();
bestSolution = solution;
}
return;
}
// Trừ dần cho các phân số bé hơn nó
for (int k = start; k <= (N + M - 1) / M; ++k) {
// Tính toán tử số mới và mẫu số mới sau khi trừ phân số 1/k
int newM = M * k - N;
int newN = N * k;
// Nếu tử số nhỏ hơn 0, tiếp tục
if (newM < 0) continue;
// Thêm phân số 1/k vào giải pháp hiện tại
solution.push_back(k);
backtrack(newM, newN, solution, k + 1); // Tiếp tục với k + 1 để tránh lặp lại các phân số
solution.pop_back(); // Quay lui để thử nghiệm phân số khác
}
}
int main() {
int M, N;
cin >> M >> N;
vector<int> solution;
backtrack(M, N, solution, 1);
cout << minCount << endl;
for (int k : bestSolution) {
cout << "1/" << k << " ";
}
cout << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9WQUxVRSA9IDEwMDA7ICAvLyDEkOG6t3QgZ2nDoSB0cuG7iyBraOG7n2kgdOG6oW8gbOG7m24gY+G7pSB0aOG7gyBjaG8gbWluQ291bnQKaW50IG1pbkNvdW50ID0gTUFYX1ZBTFVFOwp2ZWN0b3I8aW50PiBiZXN0U29sdXRpb247Cgp2b2lkIGJhY2t0cmFjayhpbnQgTSwgaW50IE4sIHZlY3RvcjxpbnQ+JiBzb2x1dGlvbiwgaW50IHN0YXJ0KSB7CiAgICAvLyBE4burbmcga2hpIHThu60gc+G7kSB24buBIDAKICAgIGlmIChNID09IDApIHsKICAgICAgICBpZiAoc29sdXRpb24uc2l6ZSgpIDwgbWluQ291bnQpIHsKICAgICAgICAgICAgbWluQ291bnQgPSBzb2x1dGlvbi5zaXplKCk7CiAgICAgICAgICAgIGJlc3RTb2x1dGlvbiA9IHNvbHV0aW9uOwogICAgICAgIH0KICAgICAgICByZXR1cm47CiAgICB9CgogICAgLy8gVHLhu6sgZOG6p24gY2hvIGPDoWMgcGjDom4gc+G7kSBiw6kgaMahbiBuw7MKICAgIGZvciAoaW50IGsgPSBzdGFydDsgayA8PSAoTiArIE0gLSAxKSAvIE07ICsraykgewogICAgICAgIC8vIFTDrW5oIHRvw6FuIHThu60gc+G7kSBt4bubaSB2w6AgbeG6q3Ugc+G7kSBt4bubaSBzYXUga2hpIHRy4burIHBow6JuIHPhu5EgMS9rCiAgICAgICAgaW50IG5ld00gPSBNICogayAtIE47CiAgICAgICAgaW50IG5ld04gPSBOICogazsKCiAgICAgICAgLy8gTuG6v3UgdOG7rSBz4buRIG5o4buPIGjGoW4gMCwgdGnhur9wIHThu6VjCiAgICAgICAgaWYgKG5ld00gPCAwKSBjb250aW51ZTsKICAgICAgICAKICAgICAgICAvLyBUaMOqbSBwaMOibiBz4buRIDEvayB2w6BvIGdp4bqjaSBwaMOhcCBoaeG7h24gdOG6oWkKICAgICAgICBzb2x1dGlvbi5wdXNoX2JhY2soayk7CiAgICAgICAgYmFja3RyYWNrKG5ld00sIG5ld04sIHNvbHV0aW9uLCBrICsgMSk7IC8vIFRp4bq/cCB04bulYyB24bubaSBrICsgMSDEkeG7gyB0csOhbmggbOG6t3AgbOG6oWkgY8OhYyBwaMOibiBz4buRCiAgICAgICAgc29sdXRpb24ucG9wX2JhY2soKTsgLy8gUXVheSBsdWkgxJHhu4MgdGjhu60gbmdoaeG7h20gcGjDom4gc+G7kSBraMOhYwogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIGludCBNLCBOOwogICAgY2luID4+IE0gPj4gTjsKCiAgICB2ZWN0b3I8aW50PiBzb2x1dGlvbjsKICAgIGJhY2t0cmFjayhNLCBOLCBzb2x1dGlvbiwgMSk7CgogICAgY291dCA8PCBtaW5Db3VudCA8PCBlbmRsOwogICAgZm9yIChpbnQgayA6IGJlc3RTb2x1dGlvbikgewogICAgICAgIGNvdXQgPDwgIjEvIiA8PCBrIDw8ICIgIjsKICAgIH0KICAgIGNvdXQgPDwgZW5kbDsKCiAgICByZXR1cm4gMDsKfQo=