#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
template <typename T>
void MACRO_VAR_Scan(T& t) {
  std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First& first, Rest&... rest) {
  std::cin >> first;
  MACRO_VAR_Scan(rest...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(20);
  cout.tie(nullptr);
  cin.tie(nullptr);
  ;
  ll k, d, t;
  MACRO_VAR_Scan(k, d, t);
  ;
  t <<= 1;
  ll whole = (k + d - 1) / d;
  ll slow = whole * d - k;
  ll cycle = 2 * k + slow;
  ll cycles = t / cycle;
  ll extra = t % cycle;
  if (extra <= 2 * k) {
    cout << ((double)cycles * (whole * d) + extra / 2.0) << endl;
  } else {
    cout << ((double)cycles * (whole * d) + k + (extra - 2 * k)) << endl;
  }
}
