#include <bits/stdc++.h>
using namespace std;
long long k, d, t;
int main() {
  while (scanf("%I64d %I64d %I64d", &k, &d, &t) == 3) {
    if (k % d == 0) {
      printf("%I64d\n", t);
      continue;
    }
    long long period;
    period = (long long)(k / d) * d + d;
    long double val = k + (period - k) * 0.5;
    long double ans = 0;
    long double temp;
    temp = ((long long)(t / val)) * val;
    ans += ((long long)(t / val)) * period;
    if ((double)(t - temp) < k)
      ans += t - temp;
    else
      ans += k + (t - temp - k) * 2;
    printf("%.25lf\n", (double)ans);
  }
  return 0;
}
