Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int gcd(int a, int b) {
  6. while (a != 0) {
  7. b = b % a;
  8. swap(a, b);
  9. }
  10. return b;
  11. }
  12.  
  13. int main() {
  14. /*ifstream fin("input.txt");
  15. ofstream fout("output.txt");*/
  16. int a, b;
  17. cin >> a >> b;
  18. if (gcd(a, b) != 1) {
  19. for (int i = 2; i < 2000000; i++) {
  20. for (int j = 2; j < 2000000; j++) {
  21. if (i * j == a * b && ((i != a && j != b) || (j != a && j != b))) {
  22. if (gcd(i, j) == a) {
  23. cout << i << " " << j;
  24. return 0;
  25. }
  26. }
  27. }
  28. }
  29. }
  30. else {
  31. cout << -1;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement