#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d;
  double t;
  cin >> k >> d >> t;
  long long c = (k + d - 1) / d;
  d *= c;
  long long z = floor(1 / ((double)k / t + (double)(d - k) / t / 2));
  double res = (double)z * (double)d;
  double tmp = 1 - z * ((double)k / t + (double)(d - k) / t / 2);
  if (tmp > 0) {
    if (tmp <= (double)k / t) {
      res += tmp * t;
    } else {
      res += k;
      tmp -= (double)k / t;
      res += tmp * t * 2;
    }
  }
  cout << fixed << setprecision(8) << res;
}
