#include <bits/stdc++.h>
double k, d, t;
int main() {
  scanf("%lf", &k);
  scanf("%lf", &d);
  scanf("%lf", &t);
  double ti;
  ti = (long long)((k - 1) / d) + 1;
  double p = ti * d;
  double ans = 0;
  double tim = (long long)(2 * t / (p + k));
  ans += tim * p;
  double rest = 2 * t - (p + k) * tim;
  if (rest < 2 * k)
    ans += rest / 2;
  else
    ans += k, ans += rest - 2 * k;
  printf("%.10f", ans);
}
