#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d, t;
  cin >> k >> d >> t;
  t <<= 1;
  double ans = 0;
  long long x = k / d, tx = 0;
  if (k % d) x++;
  tx = x * d + k;
  ans += t / tx * x * d;
  t %= tx;
  if (t <= 2 * k)
    ans += t / 2.0;
  else
    ans += t - k;
  printf("%.15lf", ans);
  return 0;
}
