#include <bits/stdc++.h>
using namespace std;
template <class s, class d>
ostream &operator<<(ostream &os, pair<s, d> x) {
  return os << "<" << x.f << ", " << x.s << "> ";
}
template <class s>
auto operator<<(ostream &os, s x) ->
    typename enable_if<!is_same<s, string>::value,
                       decltype(x.begin(), os)>::type {
  int o = 0;
  os << "{";
  for (auto c : x) {
    if (o++) os << ", ";
    os << c;
  }
  return os << "} ";
}
void dor() { cerr << endl; }
template <class s, class... t>
void dor(s x, t... y) {
  cerr << x << " ";
  dor(y...);
}
long long k, d, t;
int main() {
  scanf("%lld%lld%lld", &k, &d, &t);
  long double kk = k, tt = t;
  if (k % d == 0 || t <= k) {
    printf("%lld\n", t);
    return 0;
  }
  long long tim = d * ((k + d - 1) / d);
  long long res = 0;
  long double il = (long double)(k + tim) / (2 * tt);
  long long st = 0, en = 1e18, mid = (st + en) / 2;
  while (st <= en) {
    if (il * mid >= 1) {
      en = mid - 1;
    } else {
      st = mid + 1;
      res = max(res, mid);
    }
    mid = (st + en) / 2;
  }
  long double rest = 1.0 - mid * il;
  long double rr = 0;
  if (rest <= kk / tt) {
    rr = (long double)res * tim + rest * tt;
  } else {
    rr = (long double)res * tim + kk;
    rest -= kk / tt;
    rr += rest * tt * 2;
  }
  printf("%.10Lf\n", rr);
  return 0;
}
