#include <bits/stdc++.h>
using namespace std;
int main() {
  cout << fixed << setprecision(20);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double k, d, t, ans = 0;
  cin >> k >> d >> t;
  double larger = ((long long int)k / (long long int)d +
                   ((long long int)k % (long long int)d ? 1 : 0)) *
                  d;
  double dif = larger - k;
  double part = k / t + dif / (2 * t);
  long long int compPart = 1 / part;
  ans = compPart * larger;
  double rem = 1 - part * compPart;
  double taken = min(rem, k / t);
  ans += taken * t;
  rem -= taken;
  ans += rem * 2 * t;
  cout << ans;
}
