#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  double k, d, t, x, ans;
  long long int a, b, c, temp;
  cin >> a >> b >> c;
  if (a % b == 0)
    b = 0;
  else
    b = b - (a % b);
  k = a;
  d = b;
  t = c;
  x = k / t + d / (2 * t);
  temp = (1.0 / x);
  ans = (temp) * (k + d);
  x = 1.0 - temp * x;
  if (k / t > x)
    ans += x * t;
  else {
    ans += k;
    x -= k / t;
    ans += (2 * t) * x;
  }
  printf("%.10lf\n", ans);
  return 0;
}
