#include <bits/stdc++.h>
using namespace std;
int main() {
  double k, d, t;
  double time, time1, time2, atime, T, lost;
  long long n, m;
  scanf("%lf%lf%lf", &k, &d, &t);
  if ((long long)k % (long long)d == 0)
    printf("%lf", t);
  else {
    if (k < d) {
      time1 = k;
      time2 = (d - k) * 0.5;
      atime = d;
      time = time1 + time2;
      m = t / time;
      lost = t - m * time;
    }
    if (k > d) {
      time1 = k;
      n = k / d + 1.0;
      time2 = (n * d - k) * 0.5;
      atime = n * d;
      time = time1 + time2;
      m = t / time;
      lost = t - m * time;
    }
    if (lost <= time1) {
      T = m * atime + lost;
    } else {
      T = m * atime + time1 + (lost - time1) * 2;
    }
    printf("%lf", T);
  }
  return 0;
}
