#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, d, t;
  cin >> k >> d >> t;
  int flag = 0;
  long long int x = k % d;
  if (x != 0) {
    x = d - x;
    flag = 1;
  }
  if (flag == 0)
    cout << t << endl;
  else {
    long long int s = 2 * (k + x);
    long long int e = 2 * k + x;
    long long int r = t % e;
    long long int q = t / e;
    if (r == 0)
      cout << q * s << endl;
    else {
      long long int ti = s * q;
      if (r <= k)
        cout << ti + r << endl;
      else {
        ti += k;
        r = r - k;
        if (2 * r <= x)
          printf("%lld\n", ti + 2 * r);
        else {
          double a = r;
          double b = x;
          double c = k;
          double time = (double)ti + b;
          a = a - b / 2;
          if (a <= c) {
            printf("%lf\n", time + a);
          } else {
            time += c;
            a = a - c;
            if (2 * a <= x) printf("%lf\n", time + 2 * a);
          }
        }
      }
    }
  }
}
