#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  long long k, d, t;
  scanf("%lld %lld %lld", &k, &d, &t);
  if (k % d == 0) {
    printf("%.10lf\n", (double)t);
    return 0;
  }
  t *= 2;
  long long period = (k / d + 1) * d;
  long long periodPoints = 2 * k + period - k;
  long long nPeriods = t / periodPoints;
  long long timeSpent = nPeriods * periodPoints;
  long long rest = t - timeSpent;
  if (rest == 0) {
    printf("%.10lf\n", (double)nPeriods * period);
    return 0;
  }
  if (2 * k >= rest) {
    printf("%.10lf\n", (double)nPeriods * period + rest / 2.0);
    return 0;
  }
  printf("%.10lf\n", (double)nPeriods * period + rest - k);
}
