列出数学式子然后递归 大佬nb 注意int改成long 不然最后一组数据会溢出

#include<iostream>
#include<string>
using namespace std;

int main(){
    long a, b; //分别是分子分母
    char op; //除号
    cin >> a >> op >> b;
    while(a != 1){ //直到最后的a为1
        if(b % a == 0){ //先去掉公因子
            b = b / a;
            break;
        }
        //按照公式推算运算
        int x = b / a;
        int y = b % a;
        cout << 1 << op << x + 1 << "+";
        a -= y;
        b *= x + 1;
    }
    cout << 1 << op << b << endl;
    return 0;
}