#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void solve() {
  long double k, d, t;
  cin >> k >> d >> t;
  cout << fixed;
  cout << setprecision(10);
  if (t < k) {
    cout << t;
    return;
  }
  if ((long long)k % (long long)d == 0) {
    cout << t;
    return;
  }
  long double z = k / d;
  z++;
  long double in = (long double)(((long long int)(z)) * d);
  long double w = in - k;
  if (d > k) {
    w = d - k;
  }
  long double time = (long double)(k + ((long double)(w / (2.0))) + 0.0);
  if (t <= time) {
    cout << (long double)((long double)k + ((t - k) * 2.0));
    return;
  }
  long double mo = t / time;
  mo = (long long)(mo);
  long double ans = 0.0;
  ans = ans + (long double)(mo * k) + (long double)(mo * w);
  t = t - (long double)(mo * time);
  if (t <= k) {
    ans = ans + t;
    cout << ans;
  } else {
    ans = ans + ((long double)k + (t - k) * 2.0);
    cout << ans;
  }
}
int main() { solve(); }
