#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, INF = 1e9 + 7;
int main() {
  long long k, d, t;
  cin >> k >> d >> t;
  double ans = 0;
  if (k % d == 0) {
    ans = t;
    cout << t;
    return 0;
  }
  long long x = k, y = d - (k % d);
  long long kk = (2 * t) / (2 * x + y);
  if ((kk * (2 * x + y) + 2 * x) >= 2 * t) {
    double res = (double)kk * (x + y) + t - (1.0 * kk * (2.0 * x + y)) / 2.0;
    printf("%.12f\n", res);
  } else {
    double res = kk * (x + y) + x + 2 * t - (kk * (2 * x + y) + 2 * x);
    printf("%.12f\n", res);
  }
  return 0;
}
