#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef vector VI; typedef vector VVI; typedef vector VVVI; typedef vector VS; typedef pair PII; typedef long long LL; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) int main(){ int A,B,T; cin >> A >> B >> T; int total = 0; int hoge; if(A=0;i--){ if(T -total == 0) break; if(abs(T-total) > abs(T-(i*A+ B*ceil((double)(T-i*A)/(double)B)))){ total = (i*A+ B*ceil((T-i*A)/(double)B)); } } total = total == 0 ? B : total; cout << total << endl; return 0; }