#include <bits/stdc++.h>
using namespace std;
long long k, d, t, cnt = 0;
bool f(double T) {
  long long interval = ((long long)ceil(k / (d * 1.0))) * d;
  long long no_of_interval = T / interval;
  double t_on = no_of_interval * k, t_off = (interval - k) * no_of_interval;
  double rem = T - no_of_interval * interval;
  if (rem <= (double)k)
    t_on += rem;
  else {
    t_on += k;
    t_off += rem - k;
  }
  return t_on + t_off / 2 >= t;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> k >> d >> t;
  double s = t, e = 2 * t, mid;
  while (cnt++ <= 10000) {
    mid = (s + e) / 2;
    if (f(mid))
      e = mid;
    else
      s = mid;
  }
  cout << setprecision(20) << mid;
  return 0;
}
