#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
long long k, d, t;
int main() {
  scanf("%lld%lld%lld", &k, &d, &t);
  d = ((k - 1) / d + 1) * d;
  t <<= 1;
  long long p = 2 * k + (d - k);
  double ans = t / p * d;
  t %= p;
  double t2 = t / 2.0;
  if (t2 <= k)
    ans += t2;
  else
    ans += k + 2 * (t2 - k);
  printf("%.9f\n", ans);
  return 0;
}
