//#pragma GCC target("avx") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include "bits/stdc++.h" #pragma region library #pragma region Macros #define EXPAND(x) x #define _overload4(_1, _2, _3, _4, name, ...) name #define _overload5(_1, _2, _3, _4, _5, name, ...) name #define rep1(i, n) for (decltype(n) i = 0; i < (n); ++i) #define rep2(i, a, b) for (decltype(b) i = static_cast(a); i < (b); ++i) #define rep3(i, a, b, c) for (decltype(b) i = static_cast(a); i < (b); i += static_cast(c)) #define rept(...) EXPAND(_overload4(__VA_ARGS__, rep3, rep2, rep1, )(__VA_ARGS__)) #define per1(i, n) for (decltype(n) i = (n); i >= 0; --i) #define per2(i, a, b) for (decltype(a) i = (a); i >= static_cast(b); --i) #define per3(i, a, b, c) for (decltype(a) i = (a); i >= static_cast(b); i -= static_cast(c)) #define pert(...) EXPAND(_overload4(__VA_ARGS__, per3, per2, per1, )(__VA_ARGS__)) #define var_1(T, a) T a; read(a); #define var_2(T, a, b) T a, b; read(a, b); #define var_3(T, a, b, c) T a, b, c; read(a, b, c); #define var_4(T, a, b, c, d) T a, b, c, d; read(a, b, c, d); #define var(...) EXPAND(_overload5(__VA_ARGS__, var_4, var_3, var_2, var_1, )(__VA_ARGS__)) #define itrall(x) std::begin(x), std::end(x) using i16 = short; using i32 = int; using i64 = long long; #pragma endregion #ifndef CnM_library #define debug(x) constexpr int dx[] = { 0, 0, -1, 0 }; constexpr int dy[] = { -1, 1, 0, -1 }; template static constexpr T INF = std::numeric_limits::max() / 2; constexpr int mod = 1000000007; constexpr int mod2 = 998244353; #define elif else if #define len(T) (int)(T).size() template inline bool ckmax(T& A, const U& B) { return B > A ? A = B, true : false; } template inline bool ckmin(T& A, const U& B) { return B < A ? A = B, true : false; } struct setup_ios_deci { setup_ios_deci() { std::cout << std::fixed << std::setprecision(15); } } setup_ios_deci_; namespace lib { template inline T Pow(T A, U B) { T res(1); while (B) { if (B & 1) res *= A; A *= A; B >>= 1; } return res; } inline long long gcd(long long A, long long B) { while (B) { const long long C = A; A = B; B = C % B; } return A; } inline long long lcm(const long long A, const long long B) { return A / gcd(A, B) * B; } inline long long extgcd(long long A, long long B, long long& X, long long& Y) { long long D = A; if (B != 0) { D = extgcd(B, A % B, Y, X); Y -= (A / B) * X; return D; } else { X = 1; Y = 0; return A; } } inline long long modpow(long long A, long long B, const long long MOD) { long long res(1); while (B) { if (B & 1) res *= A, res %= MOD; A *= A; A %= MOD; B >>= 1; } return res; } template inline T inverse(T A, const T M) { T B = M, U = 1, V = 0; while (B) { T t = A / B; A -= t * B; std::swap(A, B); U -= t * V; std::swap(U, V); } U %= M; return U < 0 ? U += M, U : U; } } inline void read_sub(long long& ret) { ret = 0; bool plus_minus = true; char ch = getchar_unlocked(); while (isspace(ch)) { ch = getchar_unlocked(); } if (ch == '-') { plus_minus = false; ch = getchar_unlocked(); } for (; isdigit(ch); ch = getchar_unlocked()) { ret = (ret * 10ll) + ((long long)ch - (long long)'0'); } ungetc(ch, stdin); ret = (plus_minus ? ret : -ret); return; } inline void read_sub(int64_t& ret) { ret = 0; bool plus_minus = true; char ch = getchar_unlocked(); while (isspace(ch)) { ch = getchar_unlocked(); } if (ch == '-') { plus_minus = false; ch = getchar_unlocked(); } for (; isdigit(ch); ch = getchar_unlocked()) { ret = (ret * 10ll) + ((int64_t)ch - (int64_t)'0'); } ungetc(ch, stdin); ret = (plus_minus ? ret : -ret); return; } inline void read_sub(int& ret) { ret = 0; bool plus_minus = true; char ch = getchar_unlocked(); while (isspace(ch)) { ch = getchar_unlocked(); } if (ch == '-') { plus_minus = false; ch = getchar_unlocked(); } for (; isdigit(ch); ch = getchar_unlocked()) { ret = (ret * 10) + ((int)ch - (int)'0'); } ungetc(ch, stdin); ret = (plus_minus ? ret : -ret); return; } inline void read_sub(short& ret) { ret = 0; bool plus_minus = true; char ch = getchar_unlocked(); while (isspace(ch)) { ch = getchar_unlocked(); } if (ch == '-') { plus_minus = false; ch = getchar_unlocked(); } for (; isdigit(ch); ch = getchar_unlocked()) { ret = (ret * 10) + ((int)ch - (int)'0'); } ungetc(ch, stdin); ret = (plus_minus ? ret : -ret); return; } inline void read_sub(double& ret) { std::cin >> ret; return; } inline void read_sub(long double& ret) { std::cin >> ret; return; } inline void read_sub(char& ret) { ret = getchar_unlocked(); while (isspace(ret)) { ret = getchar_unlocked(); } return; } inline void read_sub(std::string& ret) { char ch = getchar_unlocked(); ret = ""; while (isspace(ch)) { ch = getchar_unlocked(); } for (; !isspace(ch); ch = getchar_unlocked()) { ret += ch; } ungetc(ch, stdin); return; } template inline void read_sub(std::pair& ret) { read_sub(ret.first); read_sub(ret.second); return; } template inline void read_sub(std::vector& ret) { for (T& r : ret) { read_sub(r); } return; } template inline void read(T& Tar) { read_sub(Tar); return; } template inline void read(T& Tar, Ts&... ts) { read_sub(Tar); read(ts...); return; } template inline void print(T Target) { std::cout << Target; return; } template inline void print(T Target, Ts... ts) { std::cout << Target; print(ts...); return; } #endif #pragma endregion struct TaskA { void solve() { i64 A, B, K; read(A, B, K); i64 right = INF, left = 0; while (right - left > 1) { i64 mid = (right + left) / 2; i64 S = mid / A + mid / B; S -= mid / (lib::lcm(A, B)); if (S >= K) right = mid; else left = mid; } print(right, '\n'); } }; int main(void) { TaskA solver; solver.solve(); return 0; }