#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(15);
  int64_t k, d, t, i, j, x, y;
  cin >> k >> d >> t;
  long double a, b, fval, rem, m = 0, n = 0;
  if (k <= d) {
    x = k;
    y = d - k;
  } else {
    x = k;
    if (k % d) {
      y = d - k % d;
    } else {
      y = 0;
    }
  }
  a = (long double)x / (long double)t;
  b = (long double)y / (long double)(2 * t);
  fval = (long double)1 / (long double)(a + b);
  i = floor(fval);
  rem = fval - i;
  long double z = a + b;
  rem = rem * (z);
  if ((rem - a) > 0.0) {
    m = k;
    n = (long double)(2 * t) * (long double)(rem - a);
  } else {
    m = (long double)t * (long double)rem;
  }
  cout << fixed << (long double)((long double)i * (long double)(x + y) + m + n)
       << "\n";
  return 0;
}
