#include using namespace std; #define int long long typedef pair P; int INF = 3e18+7; int mod = 1e9+7; int dx[] = {1, 0,-1, 0, 1, 1,-1,-1}; int dy[] = {0, 1, 0,-1, 1,-1, 1,-1}; int gcd(int X,int Y) { if(X%Y == 0) { return Y; } else { return gcd(Y,X%Y); } } signed main() { int A,B,K; cin >> A >> B >> K; int l = 0,r = INF; int tmp = A*B/gcd(A,B); while (l+1 < r) { int mid = (l+r)/2; if(mid/A+mid/B-mid/tmp < K) { l = mid; } else { r = mid; } } cout << r << endl; }