#include using namespace std; #include using namespace atcoder; using ll = long long; ll a,b,c; ll f(ll n){ ll nb = b*n; ll d = b - a; nb -= min(n,(nb-c)/d)*d; return nb; } void solve(){ if(a>b)swap(a,b); ll n = (c+b-1)/b; ll l = n,r = n*100; while(r-l>1){ ll m = (l+r)/2; if(f(m)> a >> b >> c; solve(); }