Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int gcd(int a, int b) {
- while (a != 0) {
- b = b % a;
- swap(a, b);
- }
- return b;
- }
- int main() {
- /*ifstream fin("input.txt");
- ofstream fout("output.txt");*/
- int a, b;
- cin >> a >> b;
- if (gcd(a, b) != 1) {
- for (int i = 2; i < 2000000; i++) {
- for (int j = 2; j < 2000000; j++) {
- if (i * j == a * b && ((i != a && j != b) || (j != a && j != b))) {
- if (gcd(i, j) == a) {
- cout << i << " " << j;
- return 0;
- }
- }
- }
- }
- }
- else {
- cout << -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement