C. Save Energy!

福禄克1775电能质量测量实战:从谐波检测到Energy Analyze数据分析全流程 本文详细介绍了福禄克1775电能质量分析仪在谐波检测与Energy Analyze数据分析中的全流程应用。从设备配置、现场测量到数据分析和问题诊断,提供了一套完整的解决方案,帮助电力工程师高效解决谐波干扰等电能质量问题,提升工业设备维护和电力系统优化效率。 阅读详情
点击打开链接

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 .

Examples
Input
Copy
3 2 6
Output
6.5
Input
Copy
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 . 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.

题的思路比较友好,不难。但是,我的基础比较烂,一些个函数的用法不明确,导致出错。

abs( )主要用于对求整数的绝对值,在“stdlib.h”(或<cstdlib>)头文件里面。

而fabs( )主要是求精度要求更高的double ,float型的绝对值,在<cmath>头文件里。

两者在只#include<cmath>时都可以使用。

所以我一直abs,一直wa.



#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<cstring>
typedef long long ll;
const double eps=1e-9;
int main()
{
	ll k,d,t;
	scanf("%lld %lld %lld",&k,&d,&t);
	if(k>=d&&k%d==0) {
		printf("%lld\n",t);
	} else {
		ll tmp=(ll)(k/d);
		ll min=(tmp+1)*d;//min time
		double val=(double)k+(min-k)*0.5;
		ll ans=(ll)t*1.0/val;
		double ed=(double)t,kk=(double)k,aans=(double)ans,mmin=(double)min;
		if(fabs(val*aans-ed)<=eps){
			printf("%.9f\n",aans*min);
		}
		else{
			double now=(aans)*val;
			if(ed-now>kk)
				printf("%.9f\n",aans*mmin+kk+(ed-now-kk)*2.0);
			else
				printf("%.9f\n",aans*mmin+(ed-now));
		}
	}
	return 0;
}



Pytorch版deeplabv3+环境配置训练自己的数据集 参考:https://blog.csdn.net/qq_36766560/article/details/110009622?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522161594607816780266214828%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=161594607816780266214828 阅读详情

相关推荐

成本150元的高性能RDP协议瘦客户机

云终端市场是一个跨度很大的市场。既有数千元的品牌的瘦客户机,也有几百元的瘦客户机,还有200-300元的支持RDP协议的多用户云终端。但是200-300元的多用户终端,在显示性能上不尽人意,一般用于地产中介门店,工厂产线的电子看板等场合。有没有性能更好,价格更低的方案呢? 答案是有。 这个方案就是 二手的x86 瘦客户机 + DoraOS瘦客户机系统免费版(仅支持RDP)。 首先我们看硬件,在某宝搜索 升腾C92 ,找到最低配置的( CPU:J1800,内存:2G,硬盘:8G)。价格都在150以内。

云飞扬的桌面云 7419

codeforces 936A Save Energy!

http://www.elijahqi.win/2018/02/26/cf936a/ 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 tur...

Elijahqi 835

【STM32】STM32 CANFD外设的几种消息接收过滤模式

在控制器区域网络(CAN)系统中,正确配置消息过滤器对于有效管理网络通信至关重要。特别是在使用Flexible Data-rate Controller Area Network(FDCAN)时,选择合适的过滤器类型可以大大提高网络效率和消息处理速度。

林愿留的博客 6240

CodeForces_937C Save Energy!(贪心)

C. Save Energy! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Julia is going to cook a chicken in the kit...

weixin_30752377的博客 222

LVGL在STM32H743IIT6上的性能优化技巧:如何提升图形界面刷新速度

本文详细介绍了在STM32H743IIT6高性能MCU上优化LVGL图形界面刷新速度的实战技巧。通过利用芯片的DMA2D硬件加速模块替代低效的软件画点,将绘制缓冲区放入SDRAM并启用双缓冲机制,以及合理配置CPU缓存与MPU,有效解决了界面卡顿问题。文章还涵盖了LVGL引擎调优、内存架构优化等关键步骤,帮助开发者充分发挥STM32H743的硬件潜力,实现流畅的图形界面体验。

vscode6remote的博客 313

IAR9.4报错之编码方式

IAR9.40编码方式错误导致的报错

qq_36081075的博客 2634

C - Save Energy!

题目链接:https://vjudge.net/contest/317253#problem/C 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 afte...

年轻过成了秃顶 471

Python爬虫实战:基于Scrapy和Playwright的深交所数据采集

本文将详细介绍如何使用Python最新技术栈(Scrapy框架结合Playwright浏览器自动化)爬取深圳证券交易所(www.szse.cn)的公开数据。文章包含完整项目搭建、反爬策略应对、数据解析存储等全流程实现,并附详细代码示例和性能优化建议。python复制下载# 上市公司基本信息# 财务数据revenue = scrapy.Field() # 营业收入net_profit = scrapy.Field() # 净利润eps = scrapy.Field() # 每股收益。

2201_76125261的博客 958

A. Save Energy!

time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJulia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the ...

xiaoxiede_wo的博客 390

Apache Kylin 命令注入漏洞复现(CVE-2020-1956)

Apache Kylin 中的静态 API 存在安全漏洞,可以将os命令与用户输入字符串连接起来,攻击者可以在Kylin没有任何保护或验证的情况下执行任何os命令。

0xSec 1562

Android 64位支持的坑:诡异的文件名问题

最近在尝试发布我的Android应用程序的更新时,遇到了一个令人困惑的64位错误。本文将详细讲解这个问题的产生原因及解决方法,供大家参考。

m0_74337424的博客 128

Codeforces Round #467 (Div. 2)-C-Save Energy!(公式)

C. Save Energy!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJulia is going to cook a chicken in the kitchen of her dormitory. To save energy, th...

信仰.的博客 720

Microsoft Bitlocker企业级管理部署方案

BitLocker是Windows 10以及更高版本中内置的磁盘加密工具,是一种可靠的数据保护机制,可以保护计算机上的敏感数据不被未经授权的人访问。BitLocker的工作原理是将整个系统卷或其他数据卷加密的同时,向某个可信软件或硬件模块请求密钥解密数据。BitLocker最大的好处在于其内置于Windows系统,所以用户无需安装其他软件或购买额外的许可证或硬件设备。本文将介绍Microsoft BitLocker企业级管理部署方案,包括:BitLocker部署前的准备工作。

xueyunshengling的博客 2079

Codeforces 937C--Save Energy!

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 ki...

包子不卖包子 562

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

Codeforces 937.C Save Energy!

C. Save Energy! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Julia is going to cook a chicken in the kitchen...

weixin_30797027的博客 140

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

【CodeForces】937 C Save Energy! 数学

http://codeforces.com/contest/937/problem/C 烤一个面包,炉开一次烤k分钟, 每过d分钟,jury都会检查炉是否在工作,如果不在工作则把它打开。 已知整个面包在炉工作的时候需要t分钟才能烤熟,若微波炉不工作的时候,依靠余温需要2t分钟才能烤熟, 问总共需要多少分钟可以烤熟。(初始微波炉是开着的,并且只要一熟就可以拿出来)。 cook的时间呈周期性...

西瓜不甜的博客 382

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Save Energy! CodeForces - 937C(周期)

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 k...

tomjobs的博客 471

CF 937C. Save Energy! 二分(精度)+数学

题意:一个炉子有两种模式:食物加热t分钟可以完成,或者在保温模式下进行2t时间.  若炉子连续加热k分钟则自动变为保温模式 . 于是小A每d分钟到炉子查看 若炉子为保温状态 则会把它变为加热状态. 给出k,d,t 若d为k的因子 则炉子保持加热状态 答案为t. 第一次变为保温的时间为k  下一次变为加热状态的时间为 k+(d- k%d) 关键:在加热k秒变保温 因为2k

noone0的博客 303

CodeForces 937C Save Energy! 水题

题意:   一个炉子烤鸡,炉子打开的时候一共$T$分钟可以烤完,关闭的时候一共$2T$分钟可以烤完,炉子每$K$分钟自动关闭,厨师每$D$分钟回来检查,打开炉子   问多长时间烤完.. 题解:    用整数写比较稳妥..    显然,整个过程是呈周期性的.    $K>D , t_r = D*(\left \lfloor\frac{K}{D} \right \rfloor +1)...

weixin_30783629的博客 158

Codeforces Round #467 (Div. 2) C. Save Energy!

C. Save Energy!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...

s540239976的博客 322

Codeforces #467 (Div. 2) C. Save Energy! ( 数学

C. Save Energy! 题目描述 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 coo...

Yishui_lovely 676

Codeforces Round #467 (Div. 2) C. Save Energy!

题目链接 找到一个时间点,这个时间点锅已经停了。那么此时可以形成一个周期,然后算出有多少这样的周期,最后处理一下结尾的点即可。(这么傻的题想了好久,太弱了) #include&lt;stdio.h&gt; #define ll long long int main() { ll k,d,t; while(~scanf("%lld%lld%lld",&amp;k,&amp;d,&...

zxy160的博客 269

AI Agent技术解析:从RPA到Energy,如何用Python构建桌面智能助手

AI Agent作为人工智能领域的重要分支,其核心在于让机器能够理解人类意图并自主执行任务。其工作原理基于大型语言模型(LLM)的自然语言理解能力,结合计算机视觉(CV)进行环境感知,通过任务规划与工具调用实现自动化操作。这项技术的价值在于将自动化从基于规则的流程驱动升级为基于目标的意图驱动,显著提升了系统的适应性和智能化水平。在应用场景上,AI Agent广泛适用于个人效率助手、软件测试、数据采集等需要人机交互的领域。本文以Energy项目为例,深入探讨了AI Agent的技术架构,并提供了使用Pytho

weixin_34416649的博客 462

Codeforces Round #467 (Div. 1): A. Save Energy!(公式)

题意:Julia准备用她刚买的炉子煮鸡蛋,这个炉子开启之后会进入加热状态,但是k分钟之后就会自动停止并进入保温状态,在加热状态下鸡蛋会每秒获得2点热量,在保温状态下鸡蛋只会每秒获得1点热量,Julin在开启炉子之后,每隔d分钟就回来看一下,如果当时炉子是保温状态,就会把它重新开启,问多少秒之后鸡蛋的热量会达到2*t先把题目理解了,翻译的应该没问题,看k,d和t这么大就应该是找公式,仔细分析一下你会...

加载中... 434

蓝牙 BlueTooth Low Energy (BLE)

BLE:(Bluetooth low energy)蓝牙4.0设备因为低耗电,也叫BLE peripheral,central:外设和中心设备,发起链接的是central(一般是指手机),被链接的设备是peripheral(运动手环) service and chara...

chuangnizhen0989的博客 351
上一篇: B. Vile Grasshoppers
下一篇: TOYS POJ - 2318
qq_36424540
博客等级 码龄10年 86粉丝 663原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值