#include <bits/stdc++.h>
using namespace std;
long long k, d, t;
long long T, T1, T2;
long long v;
double res;
int main() {
  cin >> k >> d >> t;
  if (k % d == 0) {
    res = 1.0 * t;
    printf("%f\n", res);
  } else {
    T = k + d - k % d;
    T2 = d - k % d;
    T1 = k;
    t = t * 2;
    v = 2 * k + T2;
    res = t / v * T;
    t %= v;
    if (2 * T1 >= t) {
      res += 0.5 * t;
    } else {
      res += 1.0 * T1 + 1.0 * t - 2.0 * T1;
    }
    printf("%f\n", res);
  }
  return 0;
}
