#include <bits/stdc++.h>
using namespace std;
const unsigned long long prime = 153;
const double eps = 1e-9;
const double pi = acos(-1);
const long long mod = 1e9 + 7;
int px[] = {0, 0, 1, -1, 1, -1, 1, -1};
int py[] = {1, -1, 0, 0, 1, 1, -1, -1};
int kx[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky[] = {2, -2, 1, -1, 2, -2, 1, -1};
int cycle;
long long k, d, t;
void solve() {
  long long x = (d - k % d) % d;
  long long y = (2 * t) / (k + k + x);
  long long rem = (2 * t) % (k + k + x);
  double ans = y * (k + x);
  if (rem < 2 * k)
    ans += (rem / 2.0);
  else
    ans += rem - k;
  printf("%.9lf", ans);
}
int main() {
  scanf("%lld%lld%lld", &k, &d, &t);
  solve();
}
