#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
T sqr(T x) {
  return (T)(x)*x;
}
template <typename T>
T from_string(const string &s) {
  istringstream is(s);
  T x;
  is >> x;
  return x;
}
void yes() { cout << "Lucky" << '\n'; }
void no() { cout << "Unlucky" << '\n'; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long k, d, t;
  cin >> k >> d >> t;
  if (k % d == 0) {
    cout << t << endl;
  } else {
    long long period_double_time = k;
    long long period_usual_time = k < d ? d - k : (d - k % d);
    long long period_time = period_double_time + period_usual_time;
    long long preparation_time = 2 * t;
    long long period_preparation = (2 * period_double_time + period_usual_time);
    long long periods = preparation_time / period_preparation;
    long long res = periods * period_time;
    int halfs = 0;
    preparation_time -= periods * period_preparation;
    if (preparation_time <= 2 * period_double_time) {
      res += preparation_time / 2;
      halfs += preparation_time % 2 > 0;
    } else {
      preparation_time -= 2 * period_double_time;
      res += period_double_time;
      res += preparation_time;
    }
    cout << res << (halfs > 0 ? ".5" : ".0") << endl;
  }
  return 0;
}
