#include <bits/stdc++.h>
using namespace std;
char CRTBUFF[30000];
struct debugger {
  static void call(const char* it) {}
  template <typename T, typename... aT>
  static void call(const char* it, T a, aT... rest) {
    string b;
    for (; *it && *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << "=" << a << " ";
    call(++it, rest...);
  }
};
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  long long k, d, t;
  cin >> k >> d >> t;
  cout << fixed << setprecision(15);
  long double kd = k, dd = d, td = t, pci, m, ans, rem, sz, fm;
  if (k == d) {
    cout << t << "\n";
    return 0;
  } else if (k < d) {
    sz = dd;
    pci = kd + (dd - kd) / 2;
  } else {
    sz = ceil(kd / dd) * dd;
    pci = kd + (sz - kd) / 2;
  }
  m = td / pci;
  fm = floor(m);
  ans = fm * sz;
  m = m - fm;
  rem = m * pci;
  if (rem <= kd) {
    ans += rem;
  } else {
    ans += kd;
    rem -= kd;
    ans += (rem * 2);
  }
  cout << ans << "\n";
}
