#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d, t, per, chick, inone, ans = 0;
  cin >> k >> d >> t;
  chick = 2 * t;
  if (k < d) {
    per = d;
  } else {
    per = ((k + d - 1) / d) * d;
  }
  inone = k * 2 + per - k;
  ans += chick / inone * per;
  chick %= inone;
  if (chick <= 2 * k) {
    cout << fixed << setprecision(10) << ans + (double)chick / 2 << endl;
  } else {
    cout << fixed << setprecision(10) << ans + k + (chick - 2 * k) << endl;
  }
  return 0;
}
