#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(9);
  long long k, d, t, len, res;
  long double ans = 0;
  cin >> k >> d >> t;
  if (k % d == 0)
    len = k, res = 0;
  else
    len = (k / d + 1) * d, res = len - k;
  long long tt = 2 * t / (2 * k + res);
  long double rt = 2 * t - tt * (2 * k + res);
  if (0 <= rt && rt <= 2 * k)
    ans += rt / 2;
  else
    ans += rt - k;
  ans += (k + res) * tt;
  cout << ans << endl;
  return 0;
}
