#include #include #include #include #define REP(i,k,n) for(int i=k;i> a >> b >> t; if(a < b) swap(a,b); int d = a-b; int res = 0; while(res < t) { if(res + a <= t) res += a; else res += b; } bool flag = true; while(flag) { if(res - d >= t) res -= d; else flag = false; } cout << res << endl; return 0; }