Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <vector>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <algorithm>
- #include <set>
- using namespace std;
- long long gcd(int a, int b)
- {
- if (b == 0)
- return a;
- return gcd(b, a % b);
- }
- int main()
- {
- int x, y;
- cin >> x >> y;
- if (x == y)
- {
- cout << 0 << endl;
- return 0;
- }
- if (x > y)
- swap(x, y);
- long long g = gcd(x, y);
- long long l = x / g;
- l *= y;
- cout << l - g << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement