#include <bits/stdc++.h>
using namespace std;
long long k, d, t;
int main() {
  while (cin >> k >> d >> t) {
    long long u = k / d;
    long long v = k % d;
    long long l;
    if (v)
      l = (u + 1) * d;
    else
      l = u * d;
    double c = fabs((double)(l - k) / 2) + (double)k;
    long long n = (long long)((double)t / c);
    double r = fabs((double)t - (double)n * c);
    if ((double)r > (double)k) {
      double tmp = r - (double)k;
      tmp *= 2;
      r = tmp + k;
    }
    double ans = (double)n * (double)l + r;
    printf("%lf\n", ans);
  }
  return 0;
}
