#include #include #include #include #include #include using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } // 最小公倍数 long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main() { int a, b, t; cin >> a >> b >> t; int big = max(a, b); int small = min(a, b); long long _lcm = lcm(a, b); if (small == 1) { return t; } bool isSubtract = false; if (t > _lcm) { t -= _lcm; isSubtract = true; } int pay_big, pay_small; int left; int ans = 2e9; for (int i = ceil(1.0 * t) / big; i >= 0; i--) { pay_big = i * big; left = t - pay_big; pay_small = ceil(1.0 * left / small) * small; ans = min(ans, pay_big + pay_small); } if (isSubtract) { ans += t; } cout << ans << endl; return 0; }