using static System.Math; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var a = long.Parse(line[0]); var b = long.Parse(line[1]); var k = long.Parse(line[2]); getAns(a, b, k); } static void getAns(long a, long b, long k) { if (k == 1) { Console.WriteLine(Min(a, b)); return; } if (k == 2) { Console.WriteLine(Max(a, b)); return; } var ok = long.MaxValue; var ng = 1L; while (ok - ng > 1) { var mid = ng + (ok - ng) / 2L; var chk = mid / a + mid / b - mid / lcm(a, b); if (chk >= k) ok = mid; else ng = mid; } Console.WriteLine(ok); } public static long lcm(long a, long b) { return a / gcd(a, b) * b; } static long gcd(long a, long b) { if (a < b) return gcd(b, a); while (b != 0) { var w = a % b; a = b; b = w; } return a; } }