#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, t, d, x, y;
  double ans, kk, tt, dd, xx, yy;
  cin >> k >> d >> t;
  if (k % d == 0) {
    ans = t;
    printf("%.11f\n", ans);
    return 0;
  }
  if (k > d) {
    x = k / d + 1;
    d = x * d;
  }
  kk = k;
  tt = t;
  dd = d;
  x = k + d;
  y = t * 2 / x;
  ans = dd * y;
  t = t * 2 - x * y;
  tt = t * 1.0 / 2;
  ans += min(tt, kk);
  tt -= kk;
  if (tt > 0) ans += tt * 2;
  printf("%.11f\n", ans);
  return 0;
}
