#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
void solve();
void read_input() {}
void solve() {}
const double eps = 1e-10;
int main() {
  long long k, d, t;
  cin >> k >> d >> t;
  long long on = 2;
  long long off = 1;
  if (k % d == 0) {
    cout << t << '\n';
    return 0;
  }
  long long f = k * on;
  long long small = (k / d + 1) * d - k;
  long long s = small * off;
  long long cur = 0;
  long long left = 2 * t;
  if (f >= left) {
    cout << t << '\n';
    return 0;
  }
  if (f + s >= left) {
    long long strue = (left - f) / off;
    cout << k + strue << '\n';
    return 0;
  }
  long long x = left / (f + s);
  cur += x * ((k / d + 1) * d);
  left -= x * (s + f);
  if (f >= left) {
    printf("%.10f\n", cur + left / 2.0);
  } else {
    cout << cur + k + (left - f) / off << '\n';
  }
  return 0;
}
