Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #ifndef __DEBUG__
- #define dbg(...) 42
- #endif
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = __int128;
- using pii = pair<int, int>;
- using pll = pair<ll, ll>;
- using vl = vector<ll>;
- using vi = vector<int>;
- using i128 = __int128;
- std::ostream &operator<<(std::ostream &o, const __int128 &x)
- {
- if (x < 0)
- return o << "-" << -x;
- if (x < 10)
- return o << (char) (x + '0');
- return o << x / 10 << (char) (x % 10 + '0');
- }
- i128 ext_gcd(i128 x, i128 y, i128 &a, i128 &b)
- {
- if (y == 0) {
- a = 1, b = 0;
- return x;
- }
- i128 ans = ext_gcd(y, x % y, b, a);
- b -= x / y * a;
- return ans;
- }
- int main(int argc, char **argv)
- {
- long long ox, oy;
- cin >> ox >> oy;
- i128 x = ox, y = oy, tg = 2, a, b;
- i128 g = ext_gcd(x, -y, a, b);
- // if (g > tg) { // WA should take absolute value of g;
- if (::abs(g) > tg) { // AC
- cout << -1 << endl;
- return 0;
- }
- a *= tg / g, b *= tg / g;
- cout << b << ' ' << a << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement