50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#include <algorithm>
|
|
#include <cstdio>
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
// ----- FILE IO -----
|
|
#define STDIN(filename) freopen(filename, "r", stdin)
|
|
#define STDOUT(filename) freopen(filename, "w", stdout)
|
|
#define NL '\n'
|
|
|
|
// ----- FOR LOOPS -----
|
|
#define F(i,L,R) for (int i = L; i < R; i++)
|
|
#define FE(i,L,R) for (int i = L; i <= R; i++)
|
|
#define FD(i,L,R) for (int i = L; i > R; i--)
|
|
#define FDE(i,L,R) for (int i = L; i >= R; i--)
|
|
|
|
// ----- WEZ -----
|
|
#define takeI(n) int (n); cin >> n
|
|
#define takeII(n,m) int (n),(m); cin >> n >> m
|
|
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
|
|
#define whileZ takeI(T); while(T--)
|
|
//
|
|
// ----- MAX MIN -----
|
|
#define REMAX(a,b) (a)=max((a),(b))
|
|
#define REMIN(a,b) (a)=min((a),(b))
|
|
|
|
// ----- DEBUG -----
|
|
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
|
|
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
|
|
#define printV(a) printA(a,0,a.size()-1)
|
|
|
|
// ----- STL DS
|
|
#define ALL(c) (c).begin(),(c).end()
|
|
|
|
int main() {
|
|
STDIN("pails.in");
|
|
STDOUT("pails.out");
|
|
|
|
takeIII(x,y,m);
|
|
|
|
int currX = 0, res = 0;
|
|
while (currX <= m) {
|
|
int currY = y * ((m - currX) / y);
|
|
res = max(res, currX + currY);
|
|
currX += x;
|
|
}
|
|
|
|
cout << res;
|
|
}
|