#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& vec) {
  out << "[";
  for (int x : vec) out << x << ", ";
  out << "]";
  return out;
}
unsigned long long int k, d, t;
unsigned long long int n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> k >> d >> t;
  n = (k + d - 1) / d;
  unsigned long long int m = (2ULL * t) / (k + n * d);
  double t1 = (double)t - ((double)m * ((double)n * d + (double)k) / 2.0);
  double ans = 0;
  if (t1 <= k)
    ans = t1;
  else
    ans = 2 * t1 - k;
  ans = ans + m * (n * d);
  cout.precision(20);
  cout << fixed << ans << endl;
}
