#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  double k, d, t;
  cin >> k >> d >> t;
  long long a = ceil(k / d);
  double x = k;
  double y = a * d - k;
  double s = x + y / 2.0;
  double b = floor(t / s);
  double time = b * (x + y);
  double remaining = t - b * s;
  if (remaining <= k) {
    time += remaining;
  } else {
    time += k;
    time += 2.0 * (remaining - k);
  }
  cout.precision(17);
  cout << time << endl;
  return 0;
}
