#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, d, t;
  cin >> k >> d >> t;
  long long int k1, k2;
  k1 = k;
  k2 = (k / d) * d + (int)(k % d != 0) * d - k;
  t *= 2;
  long long int bal = 2 * k1 + k2;
  long long int n = t / bal;
  double time = n * (k1 + k2);
  double extra = 1 - ((double)n / (double)t) * (double)bal;
  double work_done_by_k1 = 2 * (double)k1 / (double)t;
  double work_done_by_k2 = (double)k2 / (double)t;
  if (extra > work_done_by_k1) {
    time += (k1 + (double)(extra - work_done_by_k1) * (double)t);
  } else {
    time += (double)extra * (double)t / 2;
  }
  printf("%f\n", time);
}
