#include <bits/stdc++.h>
using namespace std;
map<int, int> ma;
int main() {
  long double k, d, t;
  cin >> k >> d >> t;
  cout << fixed << setprecision(10);
  if ((long long)k % (long long)d == 0) {
    cout << t << endl;
    return 0;
  }
  if (d < k) d = k + (d - ((long long)k % (long long)d));
  long double tmp = (d - k) / 2;
  long double comb = tmp + k;
  long double temp = ceil(t / comb);
  if (temp * comb == t)
    cout << d * temp << endl;
  else {
    temp--;
    t -= temp * comb;
    if (t <= k)
      cout << temp * d + t << endl;
    else {
      t -= k;
      cout << temp * d + k + 2 * t << endl;
    }
  }
}
