#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int const N = 100 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  ll k, d, t;
  cin >> k >> d >> t;
  cout << fixed << setprecision(12);
  if (k % d == 0) {
    cout << t;
  } else {
    ll x, y, z;
    if (k < d) {
      x = k;
      y = d - k;
    } else {
      x = k;
      y = (k / d + 1) * d - k;
    }
    z = x + y;
    t *= 2;
    double l = 0ll;
    double r = 2ll * 1000000000ll * 1000000000ll;
    for (int i = 0; i < 100000; ++i) {
      double done = 0;
      double m = (l + r) / 2;
      ll a = m / z;
      done += a * (2 * x + y);
      auto rem = m - a * z;
      auto take = min(1.0 * x, rem);
      done += 2 * take;
      rem -= take;
      done += rem;
      if (done <= t)
        l = m;
      else
        r = m;
    }
    cout << (l + r) / 2;
  }
}
