#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 6;
const double eps = 1e-8;
const double pi = acos(-1.0);
struct node {
  int x, y;
  node() {}
  node(int _x, int _y) : x(_x), y(_y) {}
};
priority_queue<int, vector<int>, greater<int> > q;
int a[maxn];
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  double k, d, t;
  scanf("%lf%lf%lf", &k, &d, &t);
  double tt = (long long)((k - 1) / d) + 1;
  double T = tt * d;
  double tim = (long long)(2 * t / (T + k));
  double ans = tim * T;
  double res = 2 * t - (T + k) * tim;
  if (res < 2 * k)
    ans += res / 2;
  else
    ans += k + (res - 2 * k);
  printf("%.10f", ans);
}
