Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on.

During cooking, Julia goes to the kitchen every d minutes and turns on the stove if it is turned off. While the cooker is turned off, it stays warm. The stove switches on and off instantly.

It is known that the chicken needs t minutes to be cooked on the stove, if it is turned on, and 2t minutes, if it is turned off. You need to find out, how much time will Julia have to cook the chicken, if it is considered that the chicken is cooked evenly, with constant speed when the stove is turned on and at a constant speed when it is turned off.

Input

The single line contains three integers k, d and t (1 ≤ k, d, t ≤ 1018).

Output

Print a single number, the total time of cooking in minutes. The relative or absolute error must not exceed 10 - 9.

Namely, let's assume that your answer is x and the answer of the jury is y. The checker program will consider your answer correct if <image>.

Examples

Input

3 2 6


Output

6.5


Input

4 2 20


Output

20.0

Note

In the first example, the chicken will be cooked for 3 minutes on the turned on stove, after this it will be cooked for <image>. Then the chicken will be cooked for one minute on a turned off stove, it will be cooked for <image>. Thus, after four minutes the chicken will be cooked for <image>. Before the fifth minute Julia will turn on the stove and after 2.5 minutes the chicken will be ready <image>.

In the second example, when the stove is turned off, Julia will immediately turn it on, so the stove will always be turned on and the chicken will be cooked in 20 minutes.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Mathematics

Sorting

Implementation


Solutions:
(k, d, t) = map(int, input().split())
if k % d == 0:
	print(t)
	exit()
r = k % d
ot = (d - r) / 2
ot += k
ct = k + (d - r)
cn = int(t // ot)
ans = cn * ct
rt = t - cn * ot
if rt < k:
	ans += rt
else:
	ans += k
	rt -= k
	ans += rt * 2
ans = '%.10f' % float(ans)
print(ans)


from math import ceil
(k, d, t) = list(map(int, input().split()))
a = ceil(k / d)
t_on = k
t_off = d * a - k
ans = 0.0
progress = t_on / t + t_off / 2 / t
k2 = int(1 / progress)
ans += float(k2) * float(t_on + t_off)
progress *= k2
rem = 1 - progress
if t_on / t >= float(rem):
	ans += rem * t
else:
	ans += t_on
	rem2 = rem - t_on / t
	ans += 2 * rem2 * t
print(ans)


(k, d, t) = map(int, input().split(' '))
nm = 0
if k % d != 0:
	p = (k // d + 1) * d
	a = k
	b = p - k
	ans = (2 * a + b) / (2 * t)
	tp = 2 * t // (2 * a + b)
	nm += tp * p
	if (2 * a + b) * tp + 2 * a >= 2 * t:
		z = ans * tp
		print(nm + (1 - z) * t)
	else:
		z = ans * tp + a / t
		print(nm + a + (1 - z) * 2 * t)
else:
	print(t)


(k, d, t) = map(int, input().split())
if k % d == 0:
	print(t)
else:
	if d >= k:
		gap = d - k
	else:
		gap = (k // d + 1) * d - k
	rd = k + gap / 2
	tt = k + gap
	ans = t // rd * tt
	rem = t - t // rd * rd
	if k >= rem:
		ans += rem
	else:
		ans += k
		rem -= k
		ans += rem * 2
	print(ans)


import math
(k, d, t) = map(int, input().strip().split(' '))
if k % d == 0:
	print(t)
elif k < d:
	x = k + (d - k) / 2
	cycle = t // x
	ans = cycle * d
	kaam = t // x * x
	kaam = t - kaam
	if kaam <= k:
		ans += kaam
	else:
		ans += k
		kaam -= k
		ans += 2 * kaam
	print(ans)
else:
	xx = math.ceil(k / d) * d
	x = k + (xx - k) / 2
	cycle = t // x
	ans = cycle * xx
	kaam = t // x * x
	kaam = t - kaam
	if kaam <= k:
		ans += kaam
	else:
		ans += k
		kaam -= k
		ans += 2 * kaam
	print(ans)


(k, d, t) = (int(x) for x in input().split())
if d >= k:
	chunksize = d
	chunkspeed = k + (d - k) / 2
else:
	if k % d == 0:
		chunksize = k
	else:
		chunksize = (k // d + 1) * d
	chunkspeed = k + (chunksize - k) / 2
chunks = int(t / chunkspeed)
ans = chunksize * chunks
rem = t - chunkspeed * chunks
if rem <= k:
	ans += rem
else:
	ans += k
	rem -= k
	ans += rem * 2
print(f'{ans:f}')


(k, d, t) = map(int, input().split())
a = 2 * k + (k + d - 1) // d * d - k
(q, r) = divmod(2 * t, a)
T = q * ((k + d - 1) // d * d)
if 0 <= r <= 2 * k:
	T += r / 2
else:
	T += k + (r - 2 * k)
print(T)


(k, d, t) = map(int, input().split())
if k >= t or k % d == 0:
	print(t)
	exit()
if d < k:
	dd = d * (k // d)
	d = dd + d
no_of_cycles = 2 * t // (k + d)
cooked = no_of_cycles * (k + d) / (2 * t)
remaining = 1 - cooked
ans = no_of_cycles * d
if remaining <= k / t:
	ans += remaining * t
else:
	remaining -= k / t
	ans += k
	ans += remaining * 2 * t
print(ans)


from math import ceil
(k, d, t) = list(map(int, input().split()))
ans = 0
y = d if d >= k else int(ceil(k / d)) * d
x = int(ceil(2.0 * t / (y + k)))
left = 1 - (y + k) / (2.0 * t) * (x - 1)
ans += (x - 1) * y
xx = left * t
if xx <= k:
	ans += xx
else:
	ans += k
	left -= k / t
	ans += 2 * t * left
print('{:.9f}'.format(ans))


from math import *
(k, d, t) = map(int, input().split())
if d < k:
	l = ceil(k / d) * d
	w = l - k
else:
	w = d - k
div = 2 * k + w
ans = 2 * t // div * (w + k)
rem = 2 * t % div
if rem != 0:
	if rem <= 2 * k:
		ans += rem / 2
	else:
		ans += rem - k
print(ans)


from math import ceil
(k, d, t, *_) = map(int, input().split())
if k > d:
	d1 = int(ceil(k / d)) * d
else:
	d1 = d
p = (k + d1) / (2 * t)
n = int(1 / p)
r = 1 - n * p
if r > k / t:
	T = n * d1 + 2 * r * t - k
else:
	T = n * d1 + r * t
print(T)


import math
(k, d, t) = map(int, input().split())
if k % d == 0 or t <= k:
	print(t)
else:
	cyc = k + (d - k % d)
	dt = k * 2 + (d - k % d)
	t *= 2
	n = t // dt
	ans = 0
	if t % dt <= k * 2:
		ans = cyc * n + t % dt / 2
	else:
		ans = cyc * n + k + (t % dt - k * 2)
	print(ans)


import math
from sys import stdin
string = stdin.readline().strip().split()
k = int(string[0])
d = int(string[1])
t = int(string[2])
if k <= d:
	T = d
	Tequal = k + (T - k) / 2
elif k % d == 0:
	T = k
	Tequal = k
else:
	T = (math.floor(k / d) + 1) * d
	Tequal = k + (T - k) / 2
round = math.floor(t / Tequal)
retime = t % Tequal
if k <= d:
	if retime <= k:
		output = round * T + retime
	else:
		output = round * T + k + (retime - k) * 2
elif retime <= k:
	output = round * T + retime
else:
	output = round * T + k + 2 * (retime - k)
print(output)


import math
(k, d, t) = map(int, input().split())
if d >= k:
	off = d - k
else:
	off = math.ceil(k / d) * d - k
times = t // (off / 2 + k)
t1 = times * (off + k)
t2 = t % (off / 2 + k)
if t2 > k:
	t2 = k + (t2 - k) * 2
ans = t1 + t2
print(ans)


(k, d, t) = map(int, input().split())
from math import gcd
if gcd(k, d) == d or k >= t:
	print(t)
	exit(0)
from fractions import Fraction
(r1a, r1b) = (Fraction(k, 1), Fraction(d - k % d, 2))
r1 = r1a + r1b
rt = Fraction(t, 1)
m = rt // r1
r = rt % r1
b = m * k + m * (d - k % d)
if r <= r1a:
	print(b + float(r))
else:
	print(b + k + 2 * float(r - r1a))


def solve(k, d, t):
	(q, r) = divmod(k, d)
	up = d - r if r != 0 else 0
	perblock2 = k * 2 + up
	(qt, rt) = divmod(2 * t, perblock2)
	if rt <= k * 2:
		extra = rt / 2
	else:
		extra = rt - k
	return (k + up) * qt + extra
(k, d, t) = [int(v) for v in input().split()]
print(solve(k, d, t))


(k, d, t) = map(int, input().split())
if k % d == 0:
	d = int(k / d) * d
else:
	d = (int(k / d) + 1) * d
tme = k + (d - k) / 2
ans = int(t / tme) * d
elap = int(t / tme) * tme
if t - elap < k:
	ans += t - elap
else:
	ans += k + (t - elap - k) * 2
print(ans)


(k, d, t) = (int(x) for x in input().split())
import math as m
if d >= k:
	chunksize = d
	chunkspeed = k + (d - k) / 2
else:
	lcm = k // m.gcd(k, d) * d
	lft = 0
	rgt = lcm // d
	while lft != rgt:
		cur = (lft + rgt) // 2
		if d * cur < k:
			lft = cur + 1
		else:
			rgt = cur
	chunksize = lft * d
	chunkspeed = k + (chunksize - k) / 2
chunks = m.floor(t / chunkspeed)
ans = chunksize * chunks
rem = t - chunkspeed * chunks
if rem <= k:
	ans += rem
else:
	ans += k
	rem -= k
	ans += rem * 2
print(ans)


(k, d, t) = (int(x) for x in input().split())
import math as m
if d >= k:
	chunksize = d
	chunkspeed = k + (d - k) / 2
else:
	if k % d == 0:
		chunksize = k
	else:
		chunksize = (k // d + 1) * d
	chunkspeed = k + (chunksize - k) / 2
chunks = m.floor(t / chunkspeed)
ans = chunksize * chunks
rem = t - chunkspeed * chunks
if rem <= k:
	ans += rem
else:
	ans += k
	rem -= k
	ans += rem * 2
print(ans)


(k, d, t) = map(int, input().split())
d = (k + d - 1) // d * d
T = 2 * t
z = T // (k + d)
fullTime = z * d
rest = T - z * (k + d)
t1 = 2 * k
if rest <= t1:
	fullTime += rest / 2
else:
	fullTime += k + (rest - t1)
print(fullTime)


(k, d, t) = [int(x) for x in input().split()]
n = 0
n = int(k / d)
if n * d == k:
	n -= 1
cycle_len = (n + 1) * d
num_cycles = int(2 * t / ((n + 1) * d + k))
remaining_minutes = t - num_cycles * (k + ((n + 1) * d - k) / 2)
if remaining_minutes < k:
	print(num_cycles * cycle_len + remaining_minutes)
else:
	print(num_cycles * cycle_len + k + (remaining_minutes - k) * 2)


def get_time(T, k, d):
	e = -(k % d)
	if e < 0:
		e += d
	C = k + e
	con = T // C * k + min(T % C, k)
	coff = T // C * e + T % C - min(T % C, k)
	return con + coff / 2
(k, d, t) = map(int, input().split())
l = 1
r = 10 ** 25
while l <= r:
	g = (l + r) / 2
	tmp = get_time(g, k, d)
	if abs(tmp - t) < 10 ** (-9):
		print(g)
		break
	if tmp < t:
		l = g
	else:
		r = g


import math
(k, d, t) = [int(i) for i in input().split()]
b = 0 if k % d == 0 else (k // d + 1) * d - k
p = k + b / 2
ans = math.floor(t / p)
tmp = t - ans * p
ans *= k + b
if tmp <= k:
	ans += tmp
else:
	ans += k
	tmp -= k
	ans += tmp * 2
print(ans)


(k, d, t) = map(int, input().split())
d = (k + d - 1) // d * d

def f(tp):
	r = 0
	dd = int(tp) // d
	tp -= d * dd
	r += (d + k) / (2 * t) * dd
	if tp <= k:
		r += tp / t
	else:
		r += k / t
		r += (tp - k) / (2 * t)
	return r
L = 0
R = 2e+18
ITR = 1000
for _ in range(ITR):
	M = (L + R) / 2.0
	if f(M) >= 1.0:
		R = M
	else:
		L = M
print('{:.10f}'.format(L))


def solve():
	(k, d, t) = [int(x) for x in input().split()]
	if k >= d and k % d == 0:
		print(t)
		return
	elif k > d:
		d = k // d * d + d
	N = 2 * t // (k + d)
	x = N * (d + k) / (2 * t)
	if x + k / t >= 1:
		y = t - N * (d + k) / 2
		res = N * d + y
	else:
		y = 2 * t - N * (d + k) - 2 * k
		res = N * d + y + k
	print(res)
solve()


(k, d, t) = input().split()
(k, d, t) = (int(k), int(d), int(t))
on = k
off = d - (k - 1) % d - 1
cycle = on + off / 2
time = (on + off) * (t // cycle)
t -= cycle * (t // cycle)
if t < k:
	print(t + time)
else:
	print(time + k + (t - k) * 2)


(k, d, t) = map(int, input().split())
if k % d == 0:
	print(t)
else:
	if d > k:
		(p, p1) = (d, k)
	else:
		p = (k // d + 1) * d
		p1 = k
	p2 = p - p1
	g = 2 * p1 + p2
	a1 = 2 * t // g * p
	a2 = min(2 * t % g / 2, p1)
	a3 = max(2 * t % g - 2 * p1, 0)
	print(a1 + a2 + a3)


import math
from decimal import Decimal

def f(k, d, t, m):
	sol = m * (d + k)
	if sol >= 2 * t:
		return True
	else:
		return False

def main():
	(k, d, t) = [int(item) for item in input().split()]
	l = 0
	r = 10 ** 18
	while r - l > 1:
		m = (l + r) // 2
		if d * m >= k:
			r = m
		else:
			l = m
	d = r * d
	l = 0
	r = 4 * t + 10
	while r - l > 1:
		m = (l + r) // 2
		if f(k, d, t, m):
			r = m
		else:
			l = m
	times = l
	last = 2 * t - times * (d + k)
	sol = times * d
	if 2 * k < last:
		last = last - 2 * k
		sol = sol + k
		sol = sol + last
	else:
		sol = sol + last / 2
	print(sol)
main()


(k, d, t) = map(int, input().split())
nocooking = (d - k % d) % d
cycle = k + nocooking
percyc = 2 * k + nocooking
goal = 2 * t
minutes = goal // percyc * cycle
goal = goal % percyc
if goal > 2 * k:
	minutes += k
	minutes += goal - 2 * k
else:
	minutes += goal / 2
print(minutes)


from math import ceil
(k, d, t) = map(int, input().split())
d = ceil(k / d) * d
(r, t) = divmod(t, k + (d - k) * 0.5)
print(r * d + min(k, t) + max(t - k, 0) * 2)


from math import ceil
(k, d, t) = [int(x) for x in input().split()]
n = ceil(k / d) * d
diff = n - k
new_k = k + diff / 2
res = t // new_k * n
if t % new_k <= k:
	res += t % new_k
else:
	res += k + (t % new_k - k) * 2
print(res)


(k, d, t) = map(int, input().split())
if k % d == 0 or k >= t:
	print(t)
else:
	if k < d:
		w1 = k
		w2 = d - k
		e = w1 / t
		r = w2 / (2 * t)
		s = e + r
	else:
		w1 = k
		w2 = d - k % d
		e = w1 / t
		r = w2 / (2 * t)
		s = e + r
	l = 1.0 // s
	ans = (w1 + w2) * l
	v = 1.0 % (e + r)
	a = 0
	if e == v:
		v -= e
		print(ans + w1)
		exit()
	if e < v:
		a = w1
		v -= e
		a += v * 2 * t
		print(ans + a)
		exit()
	a = v * t
	print(ans + a)
	exit()


(k, d, t) = map(int, input().split())
a = d - k % d
if a == d:
	a = 0
b = k + a / 2
ans = 0
ans += t // b * (k + a)
t = t % b
if t <= k:
	ans += t
else:
	ans += k + (t - k) * 2
print(ans)


import math
s = input()
s = s.split()
s = list(map(int, s))
k = s[0]
d = s[1]
t = s[2]
i = math.ceil(k / d)
c = i * d
m = (c + k) / 2
r1 = int(t / m)
remain = t - r1 * m
if remain < k:
	print(r1 * c + remain)
else:
	print(r1 * c + (remain - k) * 2 + k)


(k, d, t) = map(int, input().split())
t *= 2
if k > d:
	if k % d == 0:
		d = k
	else:
		d = (k // d + 1) * d
q = d + k
ans = t // q * d
t %= q
if t <= 2 * k:
	print(t / 2 + ans)
else:
	print(ans + t - k)


from math import ceil, floor
(k, d, t) = map(int, input().split())
period = 0
if k <= d:
	period = d
else:
	period = ceil(k / d) * d
cooking = k + period
num = floor(2 * t / cooking)
carry = 2 * t - num * cooking
ans = 0
if carry > 2 * k:
	ans = num * period + carry - k
else:
	ans = num * period + carry / 2
print(ans)


from math import ceil
(k, d, t) = map(int, input().split())
up = ceil(k / d) * d
diff = up - k
cook = diff / (2 * t) + k / t
tmp = int(1 / cook)
left = 1 - cook * tmp
ans = tmp * up
if left <= k / t:
	print(ans + left / (1 / t))
else:
	left = left - k / t
	print(ans + k + left / (1 / (2 * t)))


(k, d, t) = map(int, input().split())
if k >= t:
	print(t)
	exit()
elif k >= d and k % d == 0:
	print(t)
elif d > k:
	cycle = k + (d - k) / 2
	time_percycle = d
	time = time_percycle * (t // cycle)
	cooked = t // cycle * cycle
	time_left = t - cooked
	if time_left <= k:
		print(time_left + time)
	else:
		time_left -= k
		print(time + k + 2 * time_left)
	exit()
elif d < k:
	cycle = k + (k // d + 1) * d % k / 2
	time_percycle = (k // d + 1) * d
	time = time_percycle * (t // cycle)
	cooked = t // cycle * cycle
	time_left = t - cooked
	if time_left <= k:
		print(time_left + time)
	else:
		time_left -= k
		print(time + k + 2 * time_left)


(k, d, t) = (int(x) for x in input().split())
d_0 = d
if k > d:
	d_0 = d if k % d != 0 else 0
	d_0 += k // d * d
time = t // (k + (d_0 - k) * 0.5)
t -= (k + (d_0 - k) * 0.5) * time
if t < k:
	print(time * d_0 + t)
else:
	print(time * d_0 + k + (t - k) * 2)


(k, d, t) = map(int, input().split())
if k % d == 0:
	print(t)
elif k > d:
	tb = d * (k // d) + d
	x = tb + k
	y = tb * (2 * t // x)
	rem = 2 * t - x * (2 * t // x)
	if rem == 0:
		print(y)
	else:
		rem = rem / 2
		if rem <= k:
			print(y + rem)
		else:
			rem = rem - k
			print(y + k + 2 * rem)
else:
	x = d + k
	y = d * (t * 2 // x)
	rem = 2 * t - x * (t * 2 // x)
	if rem == 0:
		print(y)
	else:
		rem = rem / 2
		if rem <= k:
			print(y + rem)
		else:
			rem = rem - k
			print(y + k + 2 * rem)


(k, d, t) = map(int, input().split())
w = t * 2
period = (k + d - 1) // d * d
slow_per_period = (d - k % d) % d
period_w = slow_per_period + (period - slow_per_period) * 2
n_periods = w // period_w
remaining_w = w % period_w
remaining_time = 0
if remaining_w <= (period - slow_per_period) * 2:
	remaining_time = remaining_w / 2
else:
	slow_remaining_w = remaining_w - (period - slow_per_period) * 2
	remaining_time = period - slow_per_period + slow_remaining_w
print(n_periods * period + remaining_time)


(k, d, t) = [int(x) for x in input().split()]
if d >= k:
	off1 = d - k
elif k % d == 0:
	off1 = 0
else:
	off1 = d - k % d
reptime = k + off1 / 2
times = t // reptime
trest = t - times * reptime
sol = times * (k + off1)
if trest <= k:
	sol += trest
else:
	sol += k
	sol += 2 * (trest - k)
print('%.8f' % sol)


import math
(k, d, t) = [int(x) for x in input().split(' ')]
v = d * math.ceil(k / d)
cyc = k + (v - k) / 2
a = t // cyc
c = t - a * cyc - k
ans = 0
if c > 0:
	ans = c
print(t - a * cyc + a * v + ans)


raws = [int(x) for x in input().split(' ') if x]
(k, d, t) = (raws[0], raws[1], raws[2])
tp = k // d
if k % d > 0:
	tp += 1
d *= tp
rnd2 = 2 * k + (d - k)
nd = 2 * t // rnd2
ans = nd * d
rest2 = 2 * t % rnd2
if rest2 <= k * 2:
	ans += rest2 / 2
else:
	ans += k + (rest2 / 2 - k) * 2
print(ans)


(k, d, t) = map(int, input().split())
import math

def solve(k, d, t):
	if k >= d:
		d = math.ceil(k / d) * d
	cookefft = k + (d - k) / 2
	tt = d
	times = t / cookefft
	ans = int(times) * tt
	left = times % 1 * cookefft
	if left <= k:
		return ans + left
	else:
		return ans + k + (left - k) * 2
print(solve(k, d, t))


(k1, d, t) = [int(x) for x in input().split()]
k2 = int(k1 / d)
if k1 % d:
	k2 += 1
k2 = d * k2 - k1
c = int(t / (k1 + k2 / 2))
ans = c * (k1 + k2)
l = c * (k1 + k2 / 2)
t -= l
if t > k1:
	ans += k1
	t -= k1
	ans += t * 2
else:
	ans += t
print('%.9f' % ans)


(k, d, t) = input().split()
(k, d, t) = (int(k), int(d), int(t))
time = 0
if True:
	m = int((k - 1) / d) * d + d - k
	tc = k + 0.5 * m
	ta = k + m
	l = int(t / tc)
	time = ta * l
	if k > t - l * tc:
		time += t - l * tc
	else:
		time += k
		time += 2 * (t - l * tc - k)
print(time)


from math import ceil
(k, d, t) = [int(x) for x in input().split()]
if d < k:
	d = ceil(k / d) * d
c = k + (d - k) / 2
l = 0
r = int(1e+18) + 1
while l < r:
	s = (l + r) // 2
	if s * c <= t:
		l = s + 1
	else:
		r = s
l -= 1
res = l * d
t -= l * c
if t > k:
	res += k + (t - k) * 2
else:
	res += t
print(res)


import math
(k, d, t) = (int(x) for x in input().split())
d *= math.ceil(k / d)
t *= 2
(hot, warm) = (k, d - k)
answer = t // (2 * hot + warm) * (hot + warm)
t %= 2 * hot + warm
if t >= 2 * hot:
	answer += hot
	t -= 2 * hot
	answer += t
else:
	answer += t / 2
print('{:.9f}'.format(answer))


from sys import stdin, stdout
import math
import decimal as dm
(k, d, t) = [int(x) for x in stdin.readline().split()]
dm.getcontext().prec = 200
dc = (dm.Decimal(k) / dm.Decimal(d)).quantize(dm.Decimal('1'), rounding=dm.ROUND_CEILING) * dm.Decimal(d)
segp = (dc + dm.Decimal(k)) / dm.Decimal(2 * t)
segt = dc
nseg = (dm.Decimal(1.0) / segp).quantize(dm.Decimal('1'), rounding=dm.ROUND_FLOOR)
dt = nseg * segt
p = dm.Decimal(1) - nseg * segp
kseg = min(p, dm.Decimal(k) / dm.Decimal(t))
dt += kseg * dm.Decimal(t)
p -= kseg
dt += p * dm.Decimal(2 * t)
stdout.write('{:.10}\n'.format(dt))


(k, d, t) = [int(i) for i in input().split()]
t = 2 * t
if d >= k:
	s = 2 * k + (d - k)
	tt = k + (d - k)
	if s >= t:
		if 2 * k >= t:
			print(t // 2)
			exit(0)
		else:
			print(k + 2 * (t // 2 - k))
			exit(0)
	h = t // s
	x = t % s
	if x <= 2 * k:
		print(h * tt + x / 2)
	else:
		print(h * tt + k + (x - 2 * k))
else:
	last = 0
	if k % d == 0:
		last = k
	else:
		last = k - k % d + d
	s = 2 * k + (last - k)
	tt = k + (last - k)
	if s >= t:
		if 2 * k >= t:
			print(t // 2)
			exit(0)
		else:
			print(k + 2 * (t // 2 - k))
			exit(0)
	h = t // s
	x = t % s
	if x <= 2 * k:
		print(h * tt + x / 2)
	else:
		print(h * tt + k + (x - 2 * k))


import sys, math
f = sys.stdin
(K, D, T) = map(int, f.readline().split())
T = T * 2
on_time = K
if K % D > 0:
	off_time = D - K % D
else:
	off_time = 0
period_time = on_time + off_time
period_cooked = on_time * 2 + off_time
period_cnt = T // period_cooked
total_time = period_cnt * period_time
left_to_cook = T % period_cooked
if left_to_cook <= on_time * 2:
	total_time += left_to_cook / 2
else:
	total_time += on_time
	total_time += left_to_cook - on_time * 2
print(total_time)


(k, d, t) = list(map(int, input().split()))
inef_time = 2 * t
if k % d == 0:
	print(t)
	exit()
cycle_len = d * (k // d + 1)
full_cycles_effective_time = k + cycle_len
cycles_count = inef_time // full_cycles_effective_time
cycle_remnants = inef_time % full_cycles_effective_time
total_time = cycle_len * cycles_count
if cycle_remnants > 2 * k:
	total_time += k + (cycle_remnants - 2 * k)
else:
	total_time += cycle_remnants / 2
print(total_time)


(wait, cook, warm) = (0, 0, 0)
(k, d, t) = map(int, input().split())
if k % d == 0:
	print(t, '.0', sep='')
	exit()
wait = k - k % d + d
cook = k
warm = wait - cook
cooked = cook * 2 + warm
ans = t * 2 // cooked * wait
now_cooked = ans // wait * cooked
if now_cooked + k * 2 >= t * 2:
	ans *= 2
	ans += t * 2 - now_cooked
	print(ans / 2)
	exit()
else:
	now_cooked += k * 2
	ans += k
	ans += t * 2 - now_cooked
	print(ans)


(k, d, t) = map(int, input().split())
if k >= t or k % d == 0:
	print(t)
	exit()
x = d - k % d
num = 2 * t // (2 * k + x)
rem = t - num * (k + x / 2)
ans = (k + x) * num
if rem + 1e-10 <= k:
	ans += rem
else:
	ans += k + (rem - k) * 2
print(ans)


(k, d, t) = map(int, input().split())
if k % d == 0:
	ans = t
elif k < d:
	comp = k + (d - k) / 2
	md = t % comp
	ans = t // comp * d
	if md <= k:
		ans += md
	else:
		ans += k + (md - k) * 2
elif k > d:
	kek = k // d
	if k % d:
		kek += 1
	dlina = kek * d
	comp = k + (dlina - k) / 2
	md = t % comp
	ans = t // comp * dlina
	if md <= k:
		ans += md
	else:
		ans += k + (md - k) * 2
print(ans)


s = ['3', '2', '6']

def chef(s):
	s = list(map(int, s))
	(k, n, t) = (s[0], s[1], s[2])
	b = n
	if k % b == 0 or k >= t:
		return t
	if k > b:
		y = int(k / b + 1) * b
		b = y
	m = 0
	i = 0
	u = 1 / (k / t + (b - k) / (2 * t))
	i += int(u) * b
	m += int(u) * (k / t + (b - k) / (2 * t))
	if float('{0:.10f}'.format(u)) == 0:
		return i
	z = 1 - m
	if z < k / t:
		h = z * t
		i += h
	else:
		h = (z - k / t) * (2 * t)
		i += h + k
	ans = i
	return ans

def main():
	s = input().split()
	print(chef(s))
main()


(k, d, t) = list(map(float, input().split()))
if k >= t:
	print(t)
	exit(0)
if k % d == 0:
	print(t)
	exit(0)
d = k - k % d + d
ans = 1.0 // (k / t + (d - k) / (2 * t)) * d
w = 1.0 % (k / t + (d - k) / (2 * t))
if w <= k / t:
	ans += w * t
else:
	w = 1.0 % (k / t + (d - k) / (2 * t))
	w -= k / t
	ans += k
	ans += 2 * w * t
print(ans)


from math import ceil
(k, d, t) = map(int, input().split())
s = ceil(k / d) * d - k
T = k + s / 2
N = t // T
R = N * ceil(k / d) * d
ostalo = t - N * T
if ostalo <= k:
	sol = R + ostalo
else:
	sol = R + k + (ostalo - k) * 2
print(sol)


(k, d, t) = list(map(int, input().split()))
if k % d == 0:
	print(t)
	exit()
m = (k + d - 1) // d * d
if 2 * t % (m + k) == 0:
	print(m * 2 * t / (m + k))
	exit()
n = 2 * t // (m + k)
res = n * m
f = 1 - (m + k) * n / (2 * t)
if f <= k / t:
	print(res + f * t)
else:
	res += k
	f -= k / t
	print(res + f * 2 * t)


(k, d, t) = map(int, input().split())
l = int(1)
r = int(1000000000000000000)
while l < r:
	m = (l + r) // 2
	if m * d >= k:
		r = m
	else:
		l = m + 1
ck = d * l
peerck = k + (ck - k) / 2.0
l = int(0)
r = int(1000000000000000000)
while l < r:
	m = (l + r) // 2
	if (r - l) % 2 == 1:
		m = m + 1
	if peerck * m <= t:
		l = m
	else:
		r = m - 1
res = l * ck
t = t - peerck * l
if k > t:
	print(res + t)
else:
	print(res + (t - k) * 2 + k)


from math import *
(k, d, t) = map(int, input().split())
if d < k:
	d *= (k + d - 1) // d
u = float(k + (d - k) * 0.5)
ans = floor(t / u) * d
rem = t - floor(t / u) * u
if rem < k:
	ans += rem
else:
	ans += k
	rem -= k
	ans += 2 * rem
print('%.10f' % ans)


(k, d, t) = [int(x) for x in input().split()]
a = k % d
b = k // d
blok = d * (b + (1 if a > 0 else 0))
gm = b * d + a
bm = d - a if a != 0 else 0
t_per_blok = gm + 0.5 * bm
res = blok * (t // t_per_blok)
t = t % t_per_blok
res += min(t, gm)
t = max(0, t - gm)
res += 2 * t
print(res)