#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, d, t;
  cin >> k >> d >> t;
  if (k % d == 0) {
    cout << t << endl;
    return 0;
  }
  double period = k + d - k % d;
  double onetime = k + 0.5 * (d - k % d);
  long long int times = (long long int)(t / onetime);
  double cooked = times * onetime;
  double time_elapsed = times * period;
  double remaining = t - cooked;
  if (remaining <= k)
    time_elapsed += remaining;
  else {
    time_elapsed += k;
    remaining -= k;
    time_elapsed += 2 * remaining;
  }
  cout << fixed << setprecision(10);
  cout << time_elapsed << endl;
  return 0;
}
