#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, t, d;
  while (~scanf("%lld%lld%lld", &k, &d, &t)) {
    long long r;
    r = d - k % d;
    if (k % d == 0) r = 0;
    long double pt = (long double)1.0 * k / t + 1.0 * r / (2.0 * t);
    long long cnt = 1.0 / pt;
    long double ans = (long double)cnt * (k + r);
    long double res = (long double)1.0 - pt * cnt;
    if (res <= 1.0 * k / t)
      ans += res * t;
    else
      ans = ans + k + (res - (long double)1.0 * k / t) * 2.0 * t;
    printf("%.9Lf\n", ans);
  }
  return 0;
}
