#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int MAX = 300009;
const long long MOD = 1000000007;
long long pw(long long base, long long expo, long long c) {
  if (expo == 0) return 1;
  long long f = pw(base, expo / 2, c);
  if (expo & 1) return (((f * f) % c) * base) % c;
  return (f * f) % c;
}
long long k, d, t;
int main() {
  cin >> k >> d >> t;
  long long p;
  if (d >= k) {
    p = d;
  } else {
    p = (k % d == 0) ? k : (k / d + 1) * d;
  }
  long long c = k + p;
  long long n = (2 * t) / c;
  long long rem = 2 * t - n * c;
  if (rem > 2 * k) {
    double ans = n * p + rem - k;
    printf("%.12lf\n", ans);
  } else {
    double ans = n * p + rem / 2.0;
    printf("%.12lf\n", ans);
  }
  return 0;
}
