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 ≤ 10^18).


-----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 $\frac{|x - y|}{\operatorname{max}(1, y)} \leq 10^{-9}$.


-----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 $\frac{3}{6}$. Then the chicken will be cooked for one minute on a turned off stove, it will be cooked for $\frac{1}{12}$. Thus, after four minutes the chicken will be cooked for $\frac{3}{6} + \frac{1}{12} = \frac{7}{12}$. Before the fifth minute Julia will turn on the stove and after 2.5 minutes the chicken will be ready $\frac{7}{12} + \frac{2.5}{6} = 1$.

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) = list(map(int, input().split()))
off = k // d * d + d - k if k % d != 0 else 0
period = k + off
performance = off / 2 + k
part = int(t / performance)
ans = part * period
t -= part * performance
if t <= k:
	ans += t
else:
	ans += k
	t -= k
	ans += 2 * t
print(ans)


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) = [int(x) for x in input().split()]
tt = t * 2
t_loop = ((k - 1) // d + 1) * d
amount = k * 2 + (t_loop - k)
n_loop = tt // amount
rem = tt % amount
if rem <= k * 2:
	print(n_loop * t_loop + rem / 2)
else:
	print(n_loop * t_loop + rem - k)


(k, d, t) = map(int, input().split())
if d <= k:
	c = 2 * k + (d - k % d) % d
	r = 2 * t % c
	periodTime = k + (d - k % d) % d
	nrFullPeriods = 2 * t // c
	if r <= 2 * k:
		tailTime = r / 2
	else:
		tailTime = r - k
else:
	c = 2 * k + (d - k)
	r = 2 * t % c
	periodTime = d
	nrFullPeriods = 2 * t // c
	if r <= 2 * k:
		tailTime = r / 2
	else:
		tailTime = r - k
print(nrFullPeriods * periodTime + tailTime)


from math import *

def __starting_point():
	(k, d, t) = map(int, input().split())
	per = ceil(k / d) * d
	fire = k if d >= k else per - per % k
	warm = (per - fire) / 2
	ans = t // (fire + warm) * per
	remain = t - t // (fire + warm) * (fire + warm)
	if remain <= fire:
		ans += remain
	else:
		ans += fire
		remain -= fire
		ans += remain * 2
	print(ans)
__starting_point()


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


import math

def check(tim, k, d, t):
	if tim < d:
		sing = k
		dt = tim - k
		x = dt / 2 + sing
		if x >= t:
			return True
		else:
			return False
	dg = d - k
	it = math.floor(tim / d)
	sing = k * it
	doublet = dg * it
	rem = tim - sing - doublet
	if rem <= k:
		sing += rem
	else:
		sing += k
		rem -= k
		doublet += rem
	x = doublet / 2 + sing
	if x >= t:
		return True
	else:
		return False
(k, d, t) = map(int, input().split())
if t <= k or d == k:
	print(t)
else:
	d = math.ceil(k / d) * d
	if d == k:
		print(t)
	else:
		l = 0
		r = 2 * t
		mid = 0
		ans = r
		for i in range(0, 150):
			mid = (l + r) / 2
			if check(mid, k, d, t):
				r = mid
				ans = mid
			else:
				l = mid
		print(ans)


(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)


(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)


import math
(k, d, t) = map(int, input().split())
if k >= t:
	print(t)
elif k >= d and k % d == 0:
	print(t)
elif k != 0:
	p = math.ceil(k / d)
	r = p * d - k
	f = k / t + r / (2 * t)
	m = math.ceil(1 / f)
	n = m - 1
	req = 1 - n * f
	if n * f + k / t > 1:
		s = req * t
		ans = n * (p * d) + s
		print(ans)
	elif n * f + k / t == 1:
		ans = n * (p * d) + k
		print(ans)
	else:
		re = 1 - (n * f + k / t)
		s = re * (2 * t)
		ans = n * (p * d) + k + s
		print(ans)


import math
(k, d, t) = map(int, input().split())
if d == k:
	print(t)
elif k < d:
	D = 2 * t // (d + k)
	r = 2 * t % (d + k)
	if r <= 2 * k:
		print(D * d + r / 2)
	else:
		print(D * d + k + r - 2 * k)
else:
	a = math.ceil(k / d)
	D = 2 * t // (a * d + k)
	r = 2 * t % (a * d + k)
	if r <= 2 * k:
		print(D * a * d + r / 2)
	else:
		print(D * a * d + k + r - 2 * k)


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)


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))


from sys import stdin, stdout
from random import randrange
(k, d, t) = map(int, stdin.readline().split())
EPS = 10 ** (-9)
chicken = 100
d = (k + d - 1) // d * d
if False:
	stdout.write(str(chicken * t / 100))
else:
	(l, r) = (-1, 2 * t + 10)
	while r - l > 1:
		m = l + r >> 1
		cnt = m * k + m * (d - k) / 2
		if cnt * 100 / t >= 100:
			r = m
		else:
			l = m
	cnt = l * k + l * (d - k) / 2
	chicken = chicken - cnt * 100 / t
	ans = l * k + l * (d - k)
	if k * 100 / t >= chicken:
		ans += chicken * t / 100
		chicken = 0
	else:
		ans += k
		chicken -= k * 100 / t
		ans += chicken * 2 * t / 100
		chicken = 0
stdout.write(str(ans))


[k, d, t] = input().split()
k = int(k)
d = int(d)
t = int(t)
if k % d == 0:
	d = k
if k > d and k % d != 0:
	d = (k // d + 1) * d
p1 = 1.0 * k / t
p2 = 0.5 * (d - k) / t
p = p1 + p2
s = 1.0 / p
c = int(s)
z = 1.0 - p * c
if z < p1:
	ans = c * d + 1.0 * z * t
else:
	ans = c * d + k
	z = z - p1
	ans += 2.0 * z * t
template = '{:.' + str(10) + 'f}'
print(template.format(ans))


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())
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) = 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] = input().split(' ')
k = float(k)
d = float(d)
t = float(t)
T = ((k - 1) // d + 1) * d
T1 = k + (T - k) * 0.5
ans = 0
ans = ans + t // T1 * T
a = t - t // T1 * T1
if a < k:
	ans = ans + a
else:
	ans = ans + k + (a - k) * 2
print(ans)


(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) = [int(x) for x in input().split()]

def solve(k, d):
	if k > t:
		print(t)
	else:
		cook = k + (d - k) / 2
		times = t // cook
		temp = t - cook * times
		if temp > k:
			print(d * times + k + (temp - k) * 2)
		else:
			print(d * times + temp)
if k < d:
	solve(k, d)
elif k == d:
	print(t)
else:
	temp = k // d
	if temp == k / d:
		print(t)
	else:
		solve(k, (temp + 1) * d)


(k, d, t) = map(int, input().split())
time = int((k - 1) / d) / 1.0 + 1
period = time * d
result = 0
time_p = int(2 * t / (period + k)) / 1.0
result += time_p * period
rest = 2 * t - (period + k) * time_p
if rest < 2 * k:
	result += rest / 2
else:
	result += k
	result += rest - 2 * k
print('{}'.format(result))


(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))


(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)


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)


def check(m):
	r = m // time
	t1 = 2 * r * time1 + r * time2
	m %= time
	if m < time1:
		t2 = 2 * m
	else:
		t2 = 2 * time1 + (m - time1)
	return 2 * t <= t1 + t2
(k, d, t) = map(int, input().split())
time1 = k
div = (k - 1) // d + 1
time2 = d * div - k
time = time1 + time2
l = 0
r = 10 ** 20
while l < r - 1:
	m = (l + r) // 2
	if check(m / 2):
		r = m
	else:
		l = m
print(r / 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)


(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())
m = (k + d - 1) // d
extra = m * d - k
c = extra / 2.0
tot = k + c
dd = t // tot
ans = dd * (k + extra)
xx = t - dd * tot
if xx <= k:
	ans = ans + xx
else:
	ans = ans + k
	xx = xx - k
	ans = ans + xx * 2
print(float(ans))


(K, D, T) = map(int, input().split())
ivl = D * ((K + D - 1) // D)
fp = float(K) / float(ivl)
sp = 1.0 - fp
a = 0.0
b = 2.0 * T
for ii in range(300):
	t = 0.5 * (a + b)
	ivls = t // ivl
	cooked = ivls * ivl * (2.0 * fp + sp)
	rt = t - ivls * ivl
	rft = min(fp * ivl, rt)
	rsp = max(0.0, rt - rft)
	cooked += 2.0 * rft + rsp
	if cooked < 2.0 * T:
		a = t
	else:
		b = t
t = 0.5 * (a + b)
print('%.10f' % t)


(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(ans + t / 2)
else:
	print(ans + t - k)


(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)
	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) = list(map(int, input().split()))
cnt = (k + d - 1) // d
per = cnt * d
bat = k * 2 + (per - k)
cntbat = 2 * t // bat
ost = 2 * t % bat
ans = 0.0 + per * cntbat
if k * 2 >= ost:
	ans += ost / 2
else:
	ost -= 2 * k
	ans += k + ost
print(ans)


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


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)


a = input().split()
k = int(a[0])
d = int(a[1])
t = int(a[2])
if k < d:
	pp = float(k + (d - k) / 2.0)
	times = int(t / pp)
	pp = t - times * pp
	ans = float(times * d)
	if pp > k:
		ans = ans + (pp - k) * 2.0 + k
	else:
		ans = ans + pp
	print('%.9f' % ans)
elif k % d == 0:
	print('%.9f' % t)
else:
	pp = float(k + (d - k % d) / 2.0)
	times = int(t / pp)
	pp = t - times * pp
	ans = float(times * (int(k / d) + 1) * d)
	if pp > k:
		ans = ans + k + (pp - k) * 2.0
	else:
		ans = ans + pp
	print('%.9f' % ans)


(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
(k, d, t) = map(int, input().split())
onetime = max(k, k // d * d) + (math.ceil(k / d) * d - max(k, k // d * d)) / 2
realtime = math.ceil(k / d) * d
ans = t // onetime * realtime
leftt = t - t // onetime * onetime
if leftt > k:
	leftt -= k
	ans += k
	ans += leftt * 2
else:
	ans += leftt
print(ans)


import math
(k, d, t) = map(int, input().split())
l = math.ceil(k / d) * d - k
m = 2 * t // (2 * k + l)
if t - m * (k + l / 2) <= k:
	print(m * (k + l) + t - m * (k + l / 2))
else:
	print(m * (l + k) + k + 2 * (t - m * (k + l / 2) - k))


(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))


this_line = input().split()
k = int(this_line[0])
d = int(this_line[1])
t = float(this_line[2])
if k % d == 0:
	print(t)
	exit()
ans = 0.0
cook = 0.0
left = 0
if k > d:
	left = d - k % d
else:
	left = d - k
oneLoop = k + left * 0.5
loopTime = int(t / oneLoop)
ans += loopTime * (k + left)
cook += loopTime * oneLoop
if cook + k < t:
	cook += k
	ans += k
else:
	ans += t - cook
	cook = t
if cook + left * 0.5 < t:
	cook += left * 0.5
	ans += left
else:
	ans += (t - cook) * 2
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)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(k, d, t) = map(int, input().split())
d = (k + d - 1) // d * d
n = 2 * t // (d + k)
x = 2 * t % (d + k)
if x <= 2 * k:
	ans = x / 2 + d * n
else:
	ans = x - k + d * n
print(ans)


A = input().split()
k = int(A[0])
d = int(A[1])
t = int(A[2])
if k <= d:
	if t % (k + (d - k) / 2) <= k:
		dob = t % (k + (d - k) / 2)
	else:
		dob = k + 2 * (t % (k + (d - k) / 2) - k)
	tay = d * (t // (k + (d - k) / 2)) + dob
else:
	if t % (k + (d - ((k - 1) % d + 1)) / 2) <= k:
		dob = t % (k + (d - ((k - 1) % d + 1)) / 2)
	else:
		dob = k + (t % (k + (d - ((k - 1) % d + 1)) / 2) - k) * 2
	tay = t // (k + (d - ((k - 1) % d + 1)) / 2) * d * ((k - 1) // d + 1) + dob
print(tay)


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)


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


import math
(k, d, t) = input().split()
k = float(k)
d = float(d)
t = float(t)
itr = float(k / d)
itr = math.ceil(itr)
d = d * itr
cycle1 = float(k / t)
cycle2 = float((d - k) / (2 * t))
timer = d
cycle = cycle1 + cycle2
itr = 1 / cycle
itr = math.floor(itr)
if itr * cycle == 1:
	print(d * itr)
	exit()
timer = d * itr
if itr * cycle + cycle1 >= 1:
	left = 1 - itr * cycle
	print(timer + left / (1.0 / t))
else:
	timer += k
	left = 1 - itr * cycle - cycle1
	print(timer + left / (1.0 / (2.0 * t)))


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


(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()


3
(k, d, t) = (float(s) for s in input().split())
n = k // d
r = d - k % d
T = n * d
if k % d != 0:
	T += d
dt = k
if k % d != 0:
	dt += r / 2
cnt = t // dt
rem = t % dt
rest = 0
if rem < k:
	rest = rem
else:
	rest = k + (rem - k) * 2
print(cnt * T + rest)


import math
inputLine = input()
inputStr = inputLine.split(' ')
k = int(inputStr[0])
d = int(inputStr[1])
t = int(inputStr[2])
if k < d:
	m = 0
	roundValue = 0.5 * (k + d)
	m = math.ceil(t / roundValue) - 1
	t1 = t - m * roundValue
	if k >= t1:
		timeOutPut = m * d + t1
	else:
		timeOutPut = m * d + k + (t1 - k) * 2
if k >= d:
	if k % d == 0:
		timeOutPut = t
	else:
		roundTime = d - k % d + k
		m = 0
		roundValue = k + 0.5 * (d - k % d)
		m = math.ceil(t / roundValue) - 1
		leftTime = t - m * roundValue
		if leftTime <= k:
			timeOutPut = leftTime + m * roundTime
		else:
			timeOutPut = 2 * leftTime - k + m * roundTime
print(float(timeOutPut))


(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) = list(map(int, input().split()))
if k % d == 0:
	print(float(t))
	return
x = (k // d + 1) * d
y = k + (x - k) / 2
z = t // y
l = t - z * y
m = min(l, k)
l -= m
ans = z * x + m + [0, l * 2][l > 0]
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)


line1 = input().split()
fire_time = int(line1[0])
visit_time = int(line1[1])
need_time = int(line1[2])
total_time = 0

def less(fire_time, visit_time, need_time):
	total_time = 0
	every_time = fire_time + (visit_time - fire_time) / 2
	times = int(need_time / every_time)
	rest_time = need_time - times * every_time
	if rest_time == 0:
		total_time = times * visit_time
		return total_time
	else:
		if rest_time <= fire_time:
			total_time = times * visit_time + rest_time
		else:
			total_time = times * visit_time + 2 * rest_time - fire_time
		return total_time

def more(fire_time, visit_time, need_time):
	visit_time1 = 0
	if fire_time % visit_time == 0:
		visit_time1 = fire_time
	else:
		visit_time1 = fire_time // visit_time * visit_time + visit_time
	total_time = 0
	every_time = fire_time + (visit_time1 - fire_time) / 2
	times = int(need_time / every_time)
	rest_time = need_time - times * every_time
	if rest_time == 0:
		total_time = times * visit_time1
		return total_time
	else:
		if rest_time <= fire_time:
			total_time = times * visit_time1 + rest_time
		else:
			total_time = times * visit_time1 + 2 * rest_time - fire_time
		return total_time
if fire_time < visit_time:
	print(less(fire_time, visit_time, need_time))
elif fire_time == visit_time:
	print(need_time)
else:
	print(more(fire_time, visit_time, need_time))


s = input().split()
k = int(s[0])
d = int(s[1])
t = int(s[2])
if k > d:
	if k % d == 0:
		d = k
	else:
		m = int(k / d)
		d *= m + 1
v1 = 1 / t
v2 = v1 / 2
p = v1 * k + v2 * (d - k)
n = int(1 / p)
res = n * d
x = 1 % p
p1 = v1 * k
if x <= p1:
	res += x / v1
else:
	res += k
	x -= p1
	res += x / v2
if d != k:
	print(res)
else:
	print(t)


import math

def main():
	(k, d, t) = [int(x) for x in input().split()]
	time = 0.0
	k = (k, 2 * t)[k > 2 * t]
	val = d * math.ceil(k / d)
	a = t // (k + (val - k) / 2)
	b = t % (k + (val - k) / 2)
	time += val * a
	b -= k
	time += k
	if b < 0:
		time += b
	if b > 0:
		b -= (val - k) / 2
		time += val - k
		if b < 0:
			time += b * 2
	print(time)
main()


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


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)


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)


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


(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)


import math
(k, d, t) = map(int, input().split())
n = k // d
if k % d:
	n += 1
x = (k + n * d) / (2 * t)
cnt = 1 / x
cnt = math.floor(cnt)
rest = 1 - x * cnt
ans = cnt * n * d + rest * t
if k / t < rest:
	ans += (rest - k / t) * t
print(ans)


import math
(k, d, t) = map(int, input().split())
if k > d:
	turntime = math.ceil(k / d) * d
	turnvalue = k + (turntime - k) / 2
else:
	turntime = d
	turnvalue = k + (d - k) / 2
ans = t // turnvalue * turntime
t %= turnvalue
if t <= k:
	ans += t
else:
	ans += k + (t - k) * 2
print(ans)


(k, d, t) = [int(x) for x in input().split()]
n = k // d * d
h = n
if n != k:
	n = n + d
	h = (n + k) / 2
m = t // h
f = m * n
g = t - h * m
if g == 0:
	print(f)
elif g <= k:
	print(f + g)
else:
	print(f - k + 2 * g)


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)


(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) = 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)


(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 f(x):
	res = x // k1 * val
	e = x % k1
	if e <= k:
		res += e
	else:
		res += k + (e - k) / 2
	return res
(k, d, t) = map(int, input().split())
c = (k - 1) // d + 1
k1 = c * d
rem = -k % d
val = k + rem / 2
l = 0
r = 1e+50
for i in range(500):
	m = (l + r) / 2
	if f(m) >= t:
		r = m
	else:
		l = m
print('%.10f' % r)


(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))


(k, d, t) = [int(c) for c in input().split(' ')]

def find_least_mul(a, b):
	if a % b > 0:
		return a + b - a % b
	else:
		return a

def solve(k, d, t):
	ld = find_least_mul(k, d)
	ld_progress = (k + ld) / (t * 2)
	total_cycle = 1 // ld_progress
	rest_progress = 1 - ld_progress * total_cycle
	rest_time = 0
	if rest_progress > k / t:
		rest_time += k
		rest_progress -= k / t
		rest_time += rest_progress * 2 * t
	else:
		rest_time += rest_progress * t
	return total_cycle * ld + rest_time
print(solve(k, d, t))


import math

def mDiv(a, b):
	if a % b != 0:
		return a // b + 1
	else:
		return a // b
m = input().split()
d = int(m[0])
k = int(m[1])
t = int(m[2])
c = mDiv(d, k) * k
p = d + c
l = 2 * t % p
ans = c * (2 * t // p)
if l <= 2 * d:
	print(ans + l // 2, end='')
	print('.', end='')
	print(l % 2 * 5)
else:
	print(ans + l - d)


(k, d, t) = map(int, input().split())
if k < d:
	rem = d - k
	time = d
elif k % d == 0:
	rem = 0
	time = k
else:
	rem = d - k % d
	time = k + rem
interval = k + rem / 2
div = t // interval
remain = t % interval
ans = div * time + min(remain, k)
remain -= min(remain, k)
print(ans + 2 * remain)


(run, vis, cook) = map(int, input().split())
cir = (run + vis - 1) // vis
cirt = int(cir) * vis
circ = run + cirt
ans = int(2) * int(cook) // int(circ) * int(cirt)
rest = 2 * cook % (run + cir * vis)
if 2 * run >= rest:
	dans = ans + rest / 2.0
else:
	dans = ans + run + (rest - 2 * run)
print(dans)


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))


R = lambda : map(int, input().split())
(k, d, t) = R()
p = (k // d + (1 if k % d else 0)) * d
(l, r) = (0, 2 * 10 ** 18)
while (r - l) / max(1, r) > 10 ** (-10):
	m = (l + r) / 2
	ht = m // p * k + min(k, m % p)
	lt = m // p * (p - k) + max(0, m % p - k)
	if ht / t + lt / (t * 2) < 1:
		l = m
	else:
		r = m
print(l)


R = lambda : map(int, input().split())
(k, d, t) = R()
p = (k // d + (1 if k % d else 0)) * d
kp = k / t
wp = (p - k) / (2 * t)
ri = 1 // (kp + wp) * p
rm = 1 % (kp + wp)
rr = rm / kp * k if rm < kp else k + (rm - kp) / wp * (p - k)
print(ri + rr)


(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)


(k, d, t) = map(int, input().split())
t *= 2
x = (k + d - 1) // d
period = x * d
score = 2 * k + period - k
ans = t // score * period
t %= score
if t <= 2 * k:
	ans += t / 2
else:
	ans += k + (t - 2 * k)
print('%.10f' % ans)


(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)


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)


from math import ceil, floor
(k, d, t) = map(int, input().split())
count = int(ceil(k / d))
bonus = k / t + (count * d - k) / 2 / t
big_count = int(floor(1 / bonus))
leftover = 1 - bonus * big_count
answer = count * d * big_count
answer += min(leftover * t, k)
leftover -= k / t
if leftover > 0:
	answer += leftover * 2 * t
print(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))


import math
(k, d, t) = input().split()
d = int(d)
k = int(k)
t = int(t)
if k % d == 0:
	print(t)
else:
	nom = math.ceil(k / d)
	on = k
	off = (nom * d - k) / 2
	tot = on + off
	totmovs = math.floor(t / tot)
	full = totmovs * tot
	if full == t:
		print(nom * d * totmovs)
	elif full + on >= t:
		print(totmovs * d * nom + (t - full))
	else:
		print(totmovs * d * nom + on + 2 * (t - full - on))


(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))


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) = map(int, input().split())
if k % d != 0:
	low = d * (k // d + 1) - k
else:
	low = 0
ans = 0
ans_t = 0
ans = 2 * t // (2 * k + low) * (2 * k + low)
ans_t = 2 * t // (2 * k + low) * (k + low)
if ans + 2 * k >= 2 * t:
	now = 2 * t - ans
	last = now / 2
else:
	ans += 2 * k
	ans_t += k
	last = 2 * t - ans
print(last + ans_t)


import math
(k, d, t) = map(int, input().split())
if k % d == 0:
	print(t)
else:
	eps = 1e-10
	vkl = k
	p1 = math.ceil(k / d) * d
	vikl = p1 - vkl
	pribl = 1 / (vkl / t + vikl / (2 * t))
	cnt = math.floor(pribl)
	k1 = vkl / t
	k2 = vikl / (2 * t)
	ans = (vkl + vikl) * cnt
	if abs(1 - (k1 + k2) * cnt <= eps):
		print(ans)
	elif abs(1 - ((k1 + k2) * cnt + k1)) <= eps:
		print(ans + vkl)
	elif (k1 + k2) * cnt + k1 - 1.0 >= eps:
		print(ans + (1.0 - (k1 + k2) * cnt) * (t * 1.0))
	else:
		ans += vkl
		print(ans + (1.0 - (k1 + k2) * cnt - k1) * (2.0 * t))


a = [int(x) for x in input().split(' ')]
k = a[0]
d = a[1]
t = a[2]

def solve(remain):
	once = k + remain / 2
	times = t // once
	final = t % once
	if final <= k:
		timeNeed = final + times * (k + remain)
	else:
		final -= k
		timeNeed = k + final * 2 + times * (k + remain)
	print('{:.1f}'.format(timeNeed))
	pass
if k % d == 0:
	print('{:.1f}'.format(float(t)))
elif k < d:
	remain = d - k
	solve(remain)
else:
	remain = d - k % d
	solve(remain)


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))


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)


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)


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) = (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(ans)


3

def offcount(x, k, d):
	per = (k + d - 1) // d * d
	ans = x // per * (per - k)
	if x > x // per * per + k:
		ans += x - x // per * per - k
	return ans
(k, d, t) = map(int, input().split())
k *= 2
d *= 2
t *= 2
(lt, rt) = (0, 8 * 10 ** 18)
while lt < rt - 1:
	mid = (lt + rt) // 2
	if 2 * mid - offcount(mid, k, d) >= 2 * t:
		rt = mid
	else:
		lt = mid
print(rt // 2, '.', '0' if rt % 2 == 0 else '5', sep='')


import math
(k, d, t) = map(int, input().split())
timegap = ((k - 1) // d + 1) * d
donefull = k
donehalf = (timegap - k) / 2.0
done = 0
timer = 0
x = math.floor(t / (donefull + donehalf))
timer = x * timegap
done = x * (donefull + donehalf)
left = t - done
if left <= k:
	timer += left
else:
	timer += k
	left -= k
	timer += left + left
print(timer)


(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)


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)


import math
(k, d, t) = map(int, input().split())
p = math.ceil(k / d) * d
c = 2 * k + (p - k)
ans = 2 * t // c * p
t = 2 * t % c
if t <= 2 * k:
	x = t / 2.0
	ans += x
else:
	ans += t - k
print(ans)


(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)


a = input().split(' ')
k = int(a[0])
d = int(a[1])
t = int(a[2])
p = int(k / d)
l = k % d
z = d - l
if l == 0:
	z = 0
fullCycleSpeed = k / t + z / (2 * t)
rest = 1.0
fullCycleTimes = int(rest / fullCycleSpeed)
totalTime = 0
if fullCycleTimes > 0:
	rest = 1.0 - fullCycleSpeed * fullCycleTimes
	totalTime += fullCycleTimes * (k + z)
if rest < k / t:
	totalTime += rest * t
else:
	rest -= k / t
	totalTime += k
	totalTime += rest * (2 * t)
print(totalTime)


(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)


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()


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

class Q:

	def __init__(self, p=0, q=1):
		self.p = p
		self.q = q
		self.reduce()

	def reduce(self):
		d = gcd(self.p, self.q)
		self.p //= d
		self.q //= d

	def __add__(self, other):
		return Q(self.p * other.q + other.p * self.q, self.q * other.q)

	def __sub__(self, other):
		return Q(self.p * other.q - other.p * self.q, self.q * other.q)

	def __mul__(self, other):
		return Q(self.p * other.p, self.q * other.q)

	def __truediv__(self, other):
		return Q(self.p * other.q, self.q * other.p)

	def __rmul__(self, other):
		return Q(other * self.p, self.q)

	def __mod__(self, other):
		return Q(self.p * other.q % (other.p * self.q), self.q * other.q)

	def __lt__(self, other):
		return self.p * other.q < other.p * self.q

	def to_float(self):
		return self.p / self.q

	def __repr__(self):
		return '({} / {})'.format(self.p, self.q)
(k, d, t) = map(lambda x: Q(int(x)), input().split())
ne_gorit = d - k % d
if (k % d).p == 0:
	ne_gorit = Q()
cycle = k / t + ne_gorit / (2 * t)
remaining = Q(1) % cycle
full_cycles = (Q(1) - remaining) / cycle
time = full_cycles * (k + ne_gorit)
if remaining < k / t:
	print((time + remaining / (Q(1) / t)).to_float())
else:
	time += k
	remaining = remaining - k / t
	print((time + remaining / (Q(1) / (2 * t))).to_float())


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()


def el_2_A():
	list = input().split(' ')
	k = int(list[0])
	d = int(list[1])
	t = int(list[2])
	needtime = 0
	if k % d == 0:
		needtime = t
	else:
		n = k // d + 1
		round = k + n * d
		roundnum = 2 * t // round
		needtime += roundnum * d * n
		lefttime = 2 * t - roundnum * round
		if lefttime > 2 * k:
			needtime += lefttime - k
		else:
			needtime += lefttime / 2
	print(needtime)
el_2_A()


(k, d, t) = map(int, input().split())
if k / t >= 1:
	ans = t
else:
	if k % d != 0:
		m = (k // d + 1) * d
	else:
		m = k
	sp = k / t + (m - k) / (2 * t)
	tp = 1 / sp
	ans = m * int(tp)
	rp = (1 - int(tp) * sp) * t
	if k >= rp > 0:
		ans += rp
	elif rp > k:
		ans += k + (rp - k) * 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) = 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) = list(map(int, input().split()))
if k % d == 0:
	d = int(k / d) * d
else:
	d = (int(k / d) + 1) * d
p = k + (d - k) / 2
z = int(t / p) * d
e = int(t / p) * p
if t - e < k:
	z += t - e
else:
	z += k + (t - e - k) * 2
print(z)


import os
import sys
from math import *
from collections import *
from fractions import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(k, d, t) = value()
div = d * Ceil(k, d)
Fire = k / t
NotFire = (div - k) / (2 * t)
div_cook = Fire + NotFire
needed = 1 // div_cook
ans = needed * div
left = 1 - needed * div_cook
if left <= Fire:
	ans += left * t
else:
	ans += k + (left - Fire) * (2 * t)
print(ans)


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) = 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)


(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)


(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)


(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)


import math

def hello():
	(k, d, t) = list(map(int, input().split(' ')))
	if t <= k or k == d:
		print(t)
		return 0
	if k < d:
		cycle_dist = k + (d - k) / 2
		cycle_time = d
		no_cycles = int(t / cycle_dist)
		res_dist = no_cycles * cycle_dist
		res_time = no_cycles * cycle_time
		t = t - res_dist
		if t > k:
			res_time = res_time + k + 2 * (t - k)
		else:
			res_time = res_time + t
		print(res_time)
	else:
		cycle_dist = k + (math.ceil(k / d) * d - k) / 2
		cycle_time = math.ceil(k / d) * d
		no_cycles = int(t / cycle_dist)
		res_dist = no_cycles * cycle_dist
		res_time = no_cycles * cycle_time
		t = t - res_dist
		if t > k:
			res_time = res_time + k + 2 * (t - k)
		else:
			res_time = res_time + t
		print(res_time)
	return 0
hello()


from math import ceil
(k, d, t) = map(int, input().split())
timeAfterK = ceil(k / d) * d
cookingDone = k / t + (timeAfterK - k) / (2 * t)
rounds = int(1 / cookingDone)
cookingLeft = 1 - rounds * cookingDone
if cookingLeft <= k / t:
	ans = rounds * timeAfterK + cookingLeft * t
else:
	ans = rounds * timeAfterK + k
	cookingLeft -= k / t
	ans += cookingLeft * 2 * t
print('{:.10f}'.format(ans))


(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)


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


def check(x):
	X = int(x)
	r = X // d * (k + d)
	x -= X // d * d
	if x >= k:
		r += k + x
	else:
		r += 2 * x
	return r >= 2 * t
(k, d, t) = map(int, input().split())
d *= k // d + (k % d != 0)
l = 0
r = 1e+20
for i in range(200):
	med = (r + l) / 2
	if check(med):
		r = med
	else:
		l = med
print(l)


(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)


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)