#include <bits/stdc++.h>
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
long long k, d, t, s, r, p, q, m, n, l;
bool is_half;
int main() {
  scanf("%lld%lld%lld", &k, &d, &t);
  s = d * ((k + d - 1) / d);
  r = 2 * k + (s - k);
  p = (2 * t) / r;
  q = 2 * t - p * r;
  if (q <= 2 * k) {
    if (q % 2 == 1) {
      printf("%lld.5\n", p * s + q / 2);
    } else {
      printf("%lld\n", p * s + q / 2);
    }
  } else {
    printf("%lld\n", p * s + k + q - 2 * k);
  }
  return 0;
}
