#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long k, d, t;
  cin >> k >> d >> t;
  long long cyc = ((d + k - 1) / d) * d;
  long double each = k + (cyc - k) * 0.5;
  long double full = floor(t / each);
  long double left = t - (full * each);
  cout << fixed << setprecision(15);
  if (left <= k) {
    cout << full * cyc + left << "\n";
  } else {
    long double cur = full * cyc + k;
    left -= k;
    cout << cur + 2 * left << "\n";
  }
}
