Pagini recente » Cod sursa (job #1395241) | Cod sursa (job #345075) | Cod sursa (job #428448) | Cod sursa (job #1691996) | Cod sursa (job #2917242)
#include <bits/stdc++.h>
#define vt vector
#define pb push_back
#define em emplace
#define emb emplace_back
#define all(x) x.begin() + 1, x.end()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
void re() {
}
void wr() {
}
template <typename fir, typename ...sec> void re(fir &x, sec&... y) {
cin >> x;
re(y...);
}
template <typename pfir, typename psec, typename ...sec> void re(pair <pfir, psec> &x, sec&... y) {
re(x.first, x.second);
re(y...);
}
template <typename fir, typename ...sec> void re(vt <fir>& x, sec&... y) {
for(int i = 1;i < x.size();i++)
re(x[i]);
re(y...);
}
template <typename fir, typename ...sec> void wr(fir x, sec... y) {
cout << x;
wr(y...);
}
inline void Open(const string Name) {
#ifndef ONLINE_JUDGE
(void)!freopen((Name + ".in").c_str(), "r", stdin);
(void)!freopen((Name + ".out").c_str(), "w", stdout);
#endif
}
void solve() {
ll a, b; re(a, b);
auto inv = [](auto&& inv, ll a, ll b) -> ll {
return (1 < a)? b - inv(inv, b % a, a) * b / a : 1;
};
wr(inv(inv, a, b));
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
Open("inversmodular");
int t = 1;
for(;t;t--) {
solve();
}
return 0;
}