#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d, t;
  scanf("%lld %lld %lld", &k, &d, &t);
  if (k % d == 0) {
    printf("%lld", t);
    return 0;
  }
  const long long cc = k / d;
  const long double s = (cc + 1) * d;
  const long double t1 = k;
  const long double t2 = s - k;
  long double l = 0, r = 1e20;
  for (int iter = 0; iter < 100000; iter++) {
    const long double x = 0.50 * (l + r);
    const long long c = x / s;
    long double t_on = t1 * c;
    long double t_off = t2 * c;
    const long double rr = x - s * c;
    if (rr <= k) {
      t_on += rr;
    } else {
      t_on += t1;
      t_off += rr - t1;
    }
    if (t_on + 0.50 * t_off >= t) {
      r = x;
    } else {
      l = x;
    }
  }
  const double ans = 0.50 * (l + r);
  printf("%.17lf", ans);
  return 0;
}
