#include <bits/stdc++.h>
using namespace std;
const int N = 101, mod = 60;
const long long INF = 1e18 + 7;
const double PI = 3.141592653589793238462643383279502884197, EPS = 1e-7,
             two = 2.0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long k, d, t, x, y, r;
  cin >> k >> d >> t;
  t *= 2;
  x = k + (k % d ? d - k % d : 0);
  y = k * 2 + (k % d ? d - k % d : 0);
  r = t % y;
  cout << fixed << setprecision(11)
       << (t / y) * x + (r > 2 * k ? k + (r - 2 * k) : r / 2.0);
  return 0;
}
