#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long double k, d, t;
  cin >> k >> d >> t;
  long double ans = 0;
  if (k <= d) {
    long double et = (k) + (d - k) / 2.0;
    long long int ec = (t / et);
    long double lt = (t - (long double)ec * (et));
    if (lt <= k)
      ans = (long double)ec * d + lt;
    else
      ans = (long double)ec * d + k + 2 * (lt - k);
  } else {
    long long int f = ceil((k / d));
    d = (long double)(f)*d;
    long double et = (k) + (d - k) / 2.0;
    long long int ec = (t / et);
    long double lt = (t - (long double)ec * (et));
    if (lt <= k)
      ans = (long double)ec * d + lt;
    else
      ans = (long double)ec * d + k + 2 * (lt - k);
  }
  cout << fixed;
  cout << setprecision(10) << ans << endl;
}
