#include <bits/stdc++.h>
using namespace std;
int main() {
  long long k, d, t;
  cin >> k >> d >> t;
  t *= 2;
  if (k <= d) {
    long long rs = 0;
    long long c = k + d;
    rs += 2 * d * (t / c);
    long long tt = t - c * (t / c);
    if (tt <= 2 * k) {
      rs += tt;
    } else {
      rs += 2 * k;
      long long ttt = tt - 2 * k;
      rs += 2 * ttt;
    }
    if (rs % 2)
      cout << to_string(rs / 2) << ".5" << endl;
    else
      cout << to_string(rs / 2) << endl;
    return 0;
  }
  long long rs = 0;
  long long c = k / d;
  if (k % d) ++c;
  long long ct = 2 * k + c * d - k;
  rs += 2 * c * d * (t / ct);
  long long tt = t - ct * (t / ct);
  if (tt <= 2 * k) {
    rs += tt;
  } else {
    rs += 2 * k;
    long long ttt = tt - 2 * k;
    rs += 2 * ttt;
  }
  if (rs % 2)
    cout << to_string(rs / 2) << ".5" << endl;
  else
    cout << to_string(rs / 2) << endl;
  return 0;
}
