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