#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d;
  long double t;
  cin >> k >> d >> t;
  const long double chunk =
      (ceil((long double)(k) / d) * 1.0 * d - k) / 2.0 + k;
  long long lo = 0, hi = (long long)(2e18 / chunk), ans = 0;
  while (lo <= hi) {
    long long mid = lo + (hi - lo) / 2LL;
    if (chunk * mid <= t) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  long double res = (ceil((long double)(k) / d) * 1.0 * d) * ans;
  t -= chunk * ans;
  if (t <= k) {
    res += t;
  } else {
    res += k + (t - k) * 2.0;
  }
  cout << setprecision(10) << fixed << res << endl;
  return 0;
}
