#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; ///////// using namespace::std; ///////// int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// cout << setprecision(10);// int A,B,T; cin>>A>>B>>T; if(A>B){ swap(A,B); } //A<=B int An,Bn; An = (T+A-1)/A; Bn = (T+B-1)/B; //int sa = B - A; //if(sa == 0) if(A==B){ P(A*An); return 0; } //int now = B*Bn; //int BtoA = B/A; int Left = An; int ans = -1; for(int Right=0;Right <= Bn;++Right){ while(Left*A + Right*B >= T && Left >= 0){ if(ans == -1 || ans > Left*A + Right*B){ ans = Left*A + Right*B; } --Left; } ++Left; Left -= B/A; } P(ans); return 0; }