#include <bits/stdc++.h>
using namespace std;
int64_t k, d, t, s;
int main() {
  cin >> k >> d >> t;
  t *= 2;
  d = (k + d - 1) / d * d;
  s = t % (d + k);
  cout << setprecision(12) << t / (d + k) * d + (2 * k >= s ? s * .5 : s - k);
}
