#include <bits/stdc++.h>
long long k, d;
long double t;
int main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin >> k >> d >> t;
  long long ans = t / (k + ((d - k % d) % d) / 2.0);
  long long time_spent = ans * (k + (d - k % d) % d);
  t -= ans * (k + ((d - k % d) % d) / 2.0);
  std::cout.precision(10);
  if (t <= k)
    std::cout << std::fixed << time_spent + t << std::endl;
  else
    std::cout << std::fixed << (double)(time_spent + k + (t - k) * 2)
              << std::endl;
}
