#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long k, d, t;
  cin >> k >> d >> t;
  long long m1 = (k + d - 1) / d;
  long long cooked = (2 * k + m1 * d - k);
  long long m2 = 2 * t / cooked;
  long long r = (2 * t) % cooked;
  double ans = m2 * m1 * d;
  if (r <= 2 * k) {
    ans += (double)r / 2;
  } else {
    cooked += 2 * k;
    r -= k;
    ans += r;
  }
  cout << setprecision(10) << fixed << ans << '\n';
  return 0;
}
