#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d, t, lost;
  cin >> k >> d >> t;
  if (k % d == 0 || t <= k) {
    cout << t << "\n";
    return 0;
  }
  lost = d - k % d;
  long double idk = lost;
  long double pack = k + idk / 2;
  long long time = k + lost;
  long long x = t / pack;
  long double rem = t - pack * x;
  if (rem <= k) {
    cout << fixed << setprecision(9) << (long double)(x * time + rem) << "\n";
  } else {
    cout << fixed << setprecision(9)
         << (long double)(x * time + k + (rem - k) * 2) << "\n";
  }
  return 0;
}
