Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- int gcd (int a, int b, int & x, int & y)
- {
- if (a == 0)
- {
- x = 0; y = 1;
- return b;
- }
- int x1, y1;
- int d = gcd (b%a, a, x1, y1);
- x = y1 - (b / a) * x1;
- y = x1;
- return d;
- }
- int main()
- {
- int a, b, c;
- std::ifstream input("in.txt");
- std::ofstream output("out.txt");
- while (input >> a >> b >> c)
- {
- int res, x, y;
- res = gcd(a, b, x, y);
- if (c % res != 0)
- {
- output << "<none>";
- } else
- {
- output << x*c << ' ' << y*c << '\n';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement