#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
int main() {
  long long k, d, t;
  cin >> k >> d >> t;
  t *= 2;
  long long cycle = k;
  if (cycle % d) cycle += d - k % d;
  long long cycle_cook = 2 * k + cycle - k;
  long long ans = t / cycle_cook * cycle;
  t %= cycle_cook;
  if (t <= 2 * k) {
    printf("%lld", ans + t / 2);
    if (t & 1) printf(".5");
  } else {
    t -= 2 * k;
    printf("%lld", ans + k + t);
  }
  printf("\n");
  return 0;
}
