#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d, t;
  cin >> k >> d >> t;
  if (k % d == 0) {
    printf("%I64d\n", t);
  } else {
    d = (k / d + 1) * d;
    long long len = k + d;
    long long num = 2 * t / (k + d);
    double sum = num * d;
    long long left = 2 * t - num * len;
    if (left <= 2 * k)
      sum += left * 0.5;
    else {
      sum += k;
      left -= 2 * k;
      sum += (double)left;
    }
    printf("%.6lf\n", sum);
  }
}
