Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- long long X = 1, Y = 0;
- void euklides(unsigned long long a, unsigned long long b)
- {
- if (b != 0)
- {
- euklides(b, a%b);
- unsigned long long pom = Y;
- Y = X - (a / b * Y);
- X = pom;
- }
- }
- unsigned long long NWD(unsigned long long x, unsigned long long y)
- {
- while (x != 0)
- {
- int ile = y / x;
- unsigned long long t = x;
- x = y - (ile*x);
- y = t;
- }
- return y;
- }
- int main()
- {
- unsigned long long x, y;
- while (cin >> x >> y)
- {
- X = 1, Y = 0;
- euklides(x, y);
- cout << X << " " << Y << " " << NWD(x,y) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement