#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    long long k, d, t;
    cin >> k >> d >> t;
    cout << fixed << setprecision(12);
    if (t <= k) {
      cout << t << "\n";
      return 0;
    }
    if (k % d == 0) {
      cout << t;
      return 0;
    }
    t *= 2;
    long long cook = 2 * k + (d - (k % d));
    double ans = k + (d - (k % d));
    long long ntimes = t % cook;
    long long division = t / cook;
    if (ntimes == 0) {
      cout << division * ans;
      return 0;
    } else {
      if (ntimes - 2 * k < 0) {
        cout << (double)(division * ans) + (double)ntimes / 2;
        return 0;
      } else {
        cout << (double)(division * ans) + k + (double)(ntimes - 2 * k);
        return 0;
      }
    }
  }
  return 0;
}
