#include <bits/stdc++.h>
using namespace std;
long long k, d, t;
long long one;
long long one1, one2;
double oneenergy;
int main() {
  cin >> k >> d >> t;
  if (d >= k) {
    one1 = k;
    one2 = d - k;
    one = d;
  } else {
    one = (k + d - 1) / d * d;
    if (k % d)
      one2 = d - k % d;
    else
      one2 = 0;
    one1 = one - one2;
  }
  oneenergy = one1 + (one2)*0.5;
  double ans = 0;
  long long temp = t / oneenergy;
  ans += temp * one;
  double kk = t - temp * oneenergy;
  if (kk <= one1)
    ans += kk;
  else
    ans += one1 + 2 * (kk - one1);
  cout << setprecision(10) << ans << endl;
  return 0;
}
