#include <bits/stdc++.h>
using namespace std;
long long k, d, t;
int main() {
  long long cycle;
  double cycletime;
  double sum;
  while (cin >> k >> d >> t) {
    cycle = ((k - 1) / d + 1) * d;
    cycletime = (cycle - k) * 0.5 + k;
    long long number = t / cycletime;
    double fraction = t - number * cycletime;
    sum = number * cycle;
    if (fraction > double(k)) {
      sum += k + (fraction - k) * 2.0;
    } else {
      sum += fraction;
    }
    printf("%lf\n", sum);
  }
  return 0;
}
