#include <bits/stdc++.h>
using namespace std;
int main() {
  double k, d, t;
  cin >> k >> d >> t;
  double r;
  r = d - ((long long)(k) % (long long)(d));
  if (r == d) r = 0;
  double b = k + r / 2.0;
  double ans = (long long)(t / b) * (k + r);
  t = t - (((long long)(t / b) * b));
  cout.precision(17);
  if (t <= k)
    cout << ans + t;
  else {
    ans += k;
    t -= k;
    cout << ans + (t * 2);
  }
  return 0;
}
