#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int tc = 1;
  while (tc--) {
    long long k, d, t, x, y;
    cin >> k >> d >> t;
    double dd = d;
    if (k > d) {
      x = ceil(k / dd) * d;
      y = (x - k);
    } else
      y = d - k;
    long long z = 2 * k + y;
    long double ans = ((2 * t) / z) * (y + k), rem = (2 * t) % z;
    if (rem != 0) {
      if (2 * k >= rem)
        ans += (rem / 2.0);
      else
        ans += rem - k;
    }
    cout << setprecision(10) << double(ans) << endl;
  }
  return 0;
}
