Save Energy!

题意翻译

Julia打算在宿舍的厨房里煮一只鸡。为了节省能源,厨房炉子在开启后$k$分钟后自动关闭。 在烹饪过程中,Julia每隔$d$分钟就会去厨房,如果炉子是关闭的Julia就会打开炉子。当炉子关闭时,它会保持继续烹饪的状态。炉子会立即开启和关闭。 众所周知,如果炉子是开启的,鸡需要在炉子上烹饪$t$分钟;如果关闭则需要$2t$分钟。你需要知道,Julia必须要多长时间煮鸡肉。注意:鸡肉是均匀煮熟的,炉子开关时烹饪速度不变。 输入$k,d,t$,且输出与标准答案相对或绝对误差不得超过$10^{-9}$。 翻译提供者:_Los

题目描述

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.

输入输出格式

输入格式


The single line contains three integers $ k $ , $ d $ and $ t $ ( $ 1<=k,d,t<=10^{18} $ ).

输出格式


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 ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF936A/4392ea91cc80355fbf47ddfe5d10204ae8a86dac.png).

输入输出样例

输入样例 #1

3 2 6

输出样例 #1

6.5

输入样例 #2

4 2 20

输出样例 #2

20.0

说明

In the first example, the chicken will be cooked for 3 minutes on the turned on stove, after this it will be cooked for ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF936A/946fbd87d05fe2e24b8af4d0aa7735f7b1052cc7.png). Then the chicken will be cooked for one minute on a turned off stove, it will be cooked for ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF936A/a9bdc1b9aee6e89dbd96641ebe23053a20526f44.png). Thus, after four minutes the chicken will be cooked for ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF936A/6991f0a9cff42170b98fc979c8ddd5223ae7cf0e.png). Before the fifth minute Julia will turn on the stove and after $ 2.5 $ minutes the chicken will be ready ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF936A/b3b22ef8237f8837aeb119d85eaee973ea63486d.png). 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.