#include <bits/stdc++.h>
using namespace std;
int main() {
  double k, d, t;
  cin >> k >> d >> t;
  double time = 0, tp, ti, left;
  if (k > d) d = d * ceil(k / d);
  tp = k + (d - k) / 2;
  ti = floor(t / tp);
  left = t - ti * tp;
  if (left <= k)
    time = left;
  else {
    time = k + (left - k) * 2;
  }
  time += ti * d;
  cout << fixed << setprecision(9) << time;
  return 0;
}
