#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d, t, i, x, y, a;
  double p, q, ans = 0;
  cin >> k >> d >> t;
  x = ceil((double)k / d);
  y = x * d;
  p = ((double)y - k) / 2;
  q = (k + p);
  a = floor((double)t / q);
  if (t - a * q <= k)
    ans = y * a + (t - q * a);
  else {
    ans = y * a + k + (t - (k + q * a)) * 2;
  }
  cout << fixed << setprecision(6) << ans;
  return 0;
}
