/* -*- coding: utf-8 -*- * * 176.cc: No.176 2種類の切手 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ typedef long long ll; const ll LINF = 1LL << 60; /* typedef */ typedef vector vi; typedef queue qi; typedef pair pii; /* global variables */ /* subroutines */ /* main */ // a*x+b*y >= t // x >= (t-b*y)/a int main() { ll a, b, t; cin >> a >> b >> t; ll minsum = LINF; for (ll y = 0;; y++) { ll x = (t - b * y + a - 1) / a; ll sum = a * x + b * y; if (minsum > sum) minsum = sum; if (b * y > t || y > a) break; } printf("%lld\n", minsum); return 0; }