Pagini recente » Cod sursa (job #2325728) | Cod sursa (job #2311515) | Cod sursa (job #1911993) | Cod sursa (job #2112736) | Cod sursa (job #1679699)
#include <iostream>
using namespace std;
inline void gcd(int a, int b, int &d, int &x, int &y) {
if (b == 0) {
d = a;
x = 1;
y = 0;
} else {
int x0, y0;
gcd(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main() {
int x,y,d = 0;
int a,b;
a = 24;
b = 15;
int c = 147;
gcd(a,b,d,x,y);
//if(x <= 0)
//x = b + x%a;
cout << c << " " << d << " " << x << " " << y << endl;
cout << x*(c/d);
return 0;
}