#include <bits/stdc++.h>
using namespace std;
const long long int mx = 1e6 + 1, Mod = 1e9 + 7;
long long int k, d, t;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> k >> d >> t;
  t *= 2;
  long long int on = k;
  long long int off = ((k / d + (k % d > 0)) * d) - k;
  long long int all = on + off;
  long long int score = on * 2 + off;
  long double ans = (t / score) * all;
  t %= score;
  ans += min(t, 2 * on) / 2.0;
  t -= 2 * on;
  if (t > 0) ans += t;
  cout << fixed << setprecision(10) << ans << '\n';
  return 0;
}
