#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d, t;
  cin >> k >> d >> t;
  if (k % d == 0) return cout << t << endl, 0;
  if (k >= t) return cout << t << endl, 0;
  long long range = d * ceil((double)k / d);
  long long val = k + range;
  long long y = 2.0 * t / val;
  long long total = y * val;
  long long rem = 2 * t - total;
  double res = y * range;
  if (rem <= 2 * k)
    res += rem / 2.0;
  else {
    res += k;
    rem -= 2 * k;
    res += rem;
  }
  cout << fixed << setprecision(10) << res << endl;
  return 0;
}
