#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  long long k, d, t;
  scanf("%lld %lld %lld", &k, &d, &t);
  if (t <= k) {
    printf("%lld\n", t);
  } else {
    long long gape;
    if (d > k) {
      gape = d - k;
    } else {
      gape = d * ceil((double)k / d) - k;
    }
    double time = k + gape;
    double upTax = (double)k / (t);
    double offTax = (double)gape / (2 * t);
    double roundTax = upTax + offTax;
    double nRounds = floor(1 / roundTax);
    double ans = nRounds * time;
    double totalTax = nRounds * roundTax;
    if (abs(totalTax - 1) <= 0.0000000001) {
      printf("%lf\n", ans);
    } else {
      double rest = 1 - totalTax;
      if (rest <= upTax) {
        ans += (rest / upTax) * k;
      } else {
        ans += k;
        rest -= upTax;
        ans += (rest / offTax) * gape;
      }
      printf("%lf\n", ans);
    }
  }
}
