Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. int gcd (int a, int b, int & x, int & y)
  4. {
  5. if (a == 0)
  6. {
  7. x = 0; y = 1;
  8. return b;
  9. }
  10. int x1, y1;
  11. int d = gcd (b%a, a, x1, y1);
  12. x = y1 - (b / a) * x1;
  13. y = x1;
  14. return d;
  15. }
  16.  
  17. int main()
  18. {
  19. int a, b, c;
  20.  
  21. std::ifstream input("in.txt");
  22. std::ofstream output("out.txt");
  23.  
  24. while (input >> a >> b >> c)
  25. {
  26. int res, x, y;
  27. res = gcd(a, b, x, y);
  28. if (c % res != 0)
  29. {
  30. output << "<none>";
  31. } else
  32. {
  33. output << x*c << ' ' << y*c << '\n';
  34. }
  35. }
  36.  
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement