#define _GLIBCXX_DEBUG //遅い可能性がある #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(a) (a).begin(),(a).end() //lower_bound(ALL(a),x) using ll = long long; using P = pair; using VI = vector; using VVI = vector>; template bool chmax(T &a, const T& b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } template bool chmin(T &a, const T& b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } int INF = 100100100; int main() { int n,m; cin >> n >> m; VI A; while (m != 0) { int x = n / m; n -= x * m; swap(n,m); A.push_back(x); } rep(i,A.size()) { cout << A[i] << " "; } cout << endl; }