#include <bits/stdc++.h>
using namespace std;
using LD = double;
LD k, d, t;
int main() {
  scanf("%lf%lf%lf", &k, &d, &t);
  LD not_cook = 0;
  if (d < k) {
    long long pom = k / d;
    if (pom * d != k) pom = pom + (long long)1;
    not_cook = pom * d - k;
  } else
    not_cook = d - k;
  LD dod = (LD)2 * k + not_cook;
  t *= (LD)2;
  long long pel = t / dod;
  t -= pel * dod;
  LD czas = (k + not_cook) * pel;
  if (t == (LD)0) {
    printf("%.10lf", czas);
    return 0;
  }
  if (t <= (LD)2 * k) {
    czas += t / (LD)2;
    printf("%.10lf", czas);
    return 0;
  }
  czas += k;
  t -= (LD)2 * k;
  czas += t;
  printf("%.10lf", czas);
}
