#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, d, t;
  cin >> k >> d >> t;
  k *= 2;
  d *= 2;
  t *= 2;
  long long int a, b, x, y;
  a = k / d * d + k % d;
  b = (d - k % d) / 2;
  x = k;
  y = (d - k) / 2;
  cout.precision(9);
  cout << fixed;
  long long int rounds, rem, ret;
  if (k % d == 0) {
    cout << t * 0.5 << endl;
  } else if (k > d) {
    rounds = t / (a + b);
    rem = t - (a + b) * rounds;
    ret = ((k / d + 1) * d) * rounds;
    if (rem > a) {
      ret += a + (rem - a) * 2;
    } else
      ret += rem;
    cout << ret * 0.5 << endl;
  } else {
    rounds = t / (x + y);
    rem = t - (x + y) * rounds;
    ret = d * rounds;
    if (rem > x) {
      ret += x + (rem - x) * 2;
    } else
      ret += rem;
    cout << ret * 0.5 << endl;
  }
  return 0;
}
