#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int maxn = 1002;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long k, d, t;
  cout << fixed << setprecision(15);
  long double count = 0.0;
  cin >> k >> d >> t;
  if (t <= k) {
    cout << t;
    return 0;
  }
  long long interval, on, off;
  if (d > k) {
    on = k;
    off = d - k;
    interval = d;
  } else if (d == k || k % d == 0) {
    interval = k;
    on = k;
    off = 0;
  } else {
    long long q = k / d;
    q++;
    q = q * d;
    interval = q;
    on = k;
    off = q - k;
  }
  long long quo = (on * 2) + off;
  long long den = 2 * t;
  long long times = den / quo;
  count = interval * times;
  quo *= times;
  quo = den - quo;
  long long ontime = on * 2;
  long long offtime = off;
  if (quo <= ontime) {
    count = count + (quo / 2.000000000000000);
    cout << count;
    return 0;
  } else {
    count = count + on;
    quo = quo - ontime;
    count = count + quo;
    cout << count;
    return 0;
  }
  return 0;
}
