#include <bits/stdc++.h>
using namespace std;
long long k, d, t;
int main() {
  cin >> k >> d >> t;
  if (k % d == 0) {
    cout << t;
    return 0;
  }
  long long bc = (k / d + 1) * d;
  double ba = k + (double)(bc - k) / 2;
  double rez = (long long)(t / ba) * bc;
  double rest = t - (long long)(t / ba) * ba;
  if (rest <= k)
    rez += rest;
  else {
    rez += k;
    rest -= k;
    rez += rest * 2;
  }
  cout << setprecision(12) << rez;
  return 0;
}
