#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long k, d, t;
  cin >> k >> d >> t;
  long long frame = (k / d) * d;
  if (k % d != 0) frame += d;
  long long amount = 2 * k + (frame - k);
  long long req = 2 * t;
  long long pos = req / amount;
  long long rem = req % amount;
  if (rem == 0) {
    cout << pos * frame << '\n';
  } else {
    long long ans = pos * frame;
    if (rem <= 2 * k) {
      ans += rem / 2;
      if (rem % 2 == 0)
        cout << ans << '\n';
      else
        cout << ans << ".5" << '\n';
    } else {
      rem -= 2 * k;
      ans += k + rem;
      cout << ans << '\n';
    }
  }
  return 0;
}
