#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  long long K, D, T;
  cin >> K >> D >> T;
  long long cycle = K - K % D;
  if (cycle < K) cycle += D;
  long long halves_during_cycle = 2 * K + cycle - K;
  long long cycles_needed = (2 * T) / halves_during_cycle;
  long long halves = 2 * T - cycles_needed * halves_during_cycle;
  double result = cycle * cycles_needed;
  if (halves <= 2 * K)
    result += halves * 0.5;
  else
    result += K + (halves - 2 * K);
  printf("%0.1lf\n", result);
}
