#ifndef __REDUCE_H__
#define __REDUCE_H__

int gcm(int a, int b) {
    int x = a, y = b;
    if (x < y) {
        x = b;
        y = a;
    }
    int r = a % b;
    if (r == 0) return b;
    return gcm(b, r);
}

int lcm(int a, int b) {
    int g = gcm(a, b);
    return b * a / g;
}

void reduce(int x[]) {
    int a = x[0], b = x[1];
    int g = gcm(a, b);
    x[0] = a / g;
    x[1] = b / g;
}


#endif // __REDUCE_H__
