#include <bits/stdc++.h>
int main() {
  long long int k, d, t;
  scanf("%lld %lld %lld", &k, &d, &t);
  if (k % d == 0 || t <= k)
    printf("%lf", (double)t);
  else {
    long long int x;
    if (d >= k)
      x = d;
    else {
      long long int c = k / d;
      x = (c + 1) * d;
    }
    t *= 2;
    long long int p = 2 * k + (x - k);
    long long int a = t / p;
    long long int b = t - a * p;
    double T = (double)a * x;
    if (b <= 2 * k)
      T = T + (double)b / 2;
    else {
      T = T + k;
      T = T + ((double)b - 2 * k);
    }
    printf("%lf", T);
  }
  return 0;
}
