#include <bits/stdc++.h>
using namespace std;
unsigned long long k, d, t, T;
long double rez;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> k >> d >> t;
  t *= 2LL;
  T = ((k / d) + (k % d > 0)) * d;
  rez = (t / (k + T)) * T;
  t %= (k + T);
  if (t <= 2 * k)
    rez += 0.5 * t;
  else
    rez += t - k;
  cout << fixed << setprecision(6) << rez;
  return 0;
}
