#include <bits/stdc++.h>
using namespace std;
const int MOD = 999911659;
const int N = 1e5 + 3, M = 100001;
inline long long read() {
  char ch = getchar();
  long long f = 1, x = 0;
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  long long k = read(), d = read(), t = read();
  long long T = ceil(k * 1.0 / d);
  long long Ttime = T * d;
  double Ttrue = k + 0.5 * (Ttime - k);
  double needT = floor(t * 1.0 / Ttrue);
  double left = t - needT * Ttrue;
  if (left > k) left = left + left - k;
  printf("%.10f\n", needT * Ttime + left);
  return 0;
}
