#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long int ilen, k, d, t, clen;
long double lo = 0, hi = 2e18 + 1, md;
bool check(long double md) {
  long long int q = ((long long int)md / ilen);
  long double x = clen * q;
  long double ival = md - (long double)ilen * q;
  x += min(ival, (long double)clen);
  long double rt = t - x;
  if (rt <= 0) return 1;
  rt *= 2;
  long double rem = q * (ilen - clen) +
                    (ival > (long double)clen ? ival - (long double)clen : 0);
  if (rem >= rt)
    return 1;
  else
    return 0;
}
int main() {
  cin >> k >> d >> t;
  if (d >= k) {
    ilen = d;
    clen = k;
  } else {
    ilen = d * ((k / d) + (k % d > 0));
    clen = k;
  }
  for (int i = 0; i < 1000; ++i) {
    md = (lo + hi) / 2;
    if (check(md)) {
      hi = md;
    } else {
      lo = md;
    }
  }
  if (check(lo))
    cout << setprecision(10) << fixed << lo << endl;
  else
    cout << setprecision(10) << fixed << hi << endl;
}
