#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  long long k, d, t;
  cin >> k >> d >> t;
  t *= 2;
  long long vv = d - k % d;
  if (vv == d) vv = 0;
  long long al = k * 2 + vv;
  long long r = t / al;
  t = t % al;
  long long ans = r * (vv + k);
  if (t <= k * 2) {
    double kk = (double)ans + t / 2.0;
    printf("%.10lf\n", kk);
  } else {
    t -= k * 2;
    ans += k;
    ans += t;
    printf("%I64d\n", ans);
  }
  return 0;
}
