#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector VI; typedef pair PI; const double EPS=1e-9; ll a, b, t; ll f(ll v) { ll res = a * v + max((t - a * v + b - 1) / b * b, 0LL); cerr << "f(" << v<< ")=" << res << endl; return res; } int main(void){ cin >> a >> b >> t; if (a < b) { swap(a, b); } ll x = 0, y = 1LL << 33; while (y - x >= 10) { ll z = (2 * x + y) / 3; ll w = (x + 2 * y) / 3; if (f(z) < f(w)) { y = w; } else { x = z; } cerr << "x="<