#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void read(T &...args) {
  ((cin >> args), ...);
};
template <typename... T>
void write(T &&...args) {
  ((cout << args << " "), ...);
  cout << "\n";
};
bool isValidSolution(double x, long long int y, long long int cd,
                     long long int k) {
  long long int minX = (k + (y - 1) * cd) - ((y - 1) * (cd - k));
  long long int maxX = (k + y * cd) - (y * (cd - k));
  if (x >= minX && x <= maxX)
    return true;
  else
    return false;
};
double EPS = 0.000000000001;
int main() {
  long long int k, d, t;
  read(k, d, t);
  if (k % d == 0) {
    cout << t << "\n";
  } else {
    long long int wOff = d - (k % d);
    long long int wOn = k;
    long long int numInterval = 2 * t / (2 * wOn + wOff);
    double rem = t - (numInterval * 1.0 * (wOn + wOff / 2.0));
    double ans = (wOn + wOff) * numInterval;
    if (rem + EPS <= k)
      ans += rem;
    else
      ans += wOn + (rem - k) * 2.0;
    cout << fixed << setprecision(11) << ans;
  }
  return 0;
};
