CF936A.Save Energy!

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 2_t_ 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.

朱莉娅将在宿舍的厨房里烹饪一只鸡。为了节约能源,厨房的灶台在开启后自动运行 kk 分钟,然后自动关闭。

在烹饪过程中,朱莉娅每隔 dd 分钟就去一次厨房;若此时灶台已关闭,则她会立即将其重新开启。灶台关闭期间,锅具仍能保持一定温度。灶台的开启与关闭均为瞬时完成。

已知:若灶台始终开启,鸡需要 tt 分钟才能煮熟;若灶台始终关闭,则需要 2t2t 分钟才能煮熟。假设鸡的熟化过程是均匀的——即灶台开启时熟化速度恒定,灶台关闭时熟化速度也恒定(但较慢),请计算朱莉娅总共需要多少时间才能将鸡完全煮熟。

输入格式

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

单行包含三个整数 kk、dd 和 tt(1 ≤ k, d, t ≤ 10181 ≤ 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 .

输出一个整数,表示烹饪的总时间(单位:分钟)。相对误差或绝对误差不得超过 10−910^{-9}。

即,假设你的答案为 xx,评测组的答案为 yy。当满足 时,评测程序将判定你的答案正确。

输入输出样例

  • 输入#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 . Then the chicken will be cooked for one minute on a turned off stove, it will be cooked for . Thus, after four minutes the chicken will be cooked for . Before the fifth minute Julia will turn on the stove and after 2.5 minutes the chicken will be ready .

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.

在第一个例子中,鸡肉将在开启的炉灶上烹饪 3 分钟,之后将继续烹饪 。接着,鸡肉将在关闭的炉灶上烹饪 1 分钟,期间将被烹饪 。因此,经过 4 分钟后,鸡肉总共被烹饪了 。在第 5 分钟开始前,朱莉娅将重新开启炉灶,再经过 2.5 分钟,鸡肉即可完成烹饪 。

在第二个例子中,每当炉灶关闭时,朱莉娅会立即将其开启,因此炉灶将始终保持开启状态,鸡肉将在 20 分钟内完成烹饪。

输入解题思路,AI测评打分。不知道怎么写?

首页