Codeforces 799A Carrot Cakes 题解
来源:互联网 发布:python 共享内存对象 编辑:程序博客网 时间:2024/06/07 06:11
题意
现在有n个胡萝卜,一个炉子,一个炉子可以同时做k个胡萝卜,做好需要t分钟,现在允许用d分钟再造一个相同的炉子,两个炉子可以同时工作,判断再建一个炉子是否可以缩短总时间
思路
分别计算建不建炉子的时间进行比较,先计算一共需要做多少次胡萝卜,就是(n+1)/k,然后再乘t就是不建的,建的首先算出在建的时候能做多少次胡萝卜,减去后剩下的平分两个炉子,奇数时给原先的炉子多一次,计算出总时间,然后比较
代码
#include <cstdio>#include <algorithm>using namespace std;int main(){ int n,t,k,d,t1,t2,t3; scanf("%d%d%d%d",&n,&t,&k,&d); if(n%k==0) n/=k; else n=n/k+1; t1=n*t; if(n*t<=d) { t2=d; t3=d; } else { t2=d; t3=d/t*t; n-=d/t; if(n%2==1) t2=t3+(n/2+1)*t; else t2=t2+n/2*t; } if(t1>t2) printf("YES\n"); else printf("NO\n"); return 0;}
0 0
- Codeforces 799A Carrot Cakes 题解
- Codeforces Round #413 Div. 1 + Div. 2 A. Carrot Cakes
- codeforces Round #413 Div. 1 + Div. 2 A Carrot Cakes
- codeforces Round #413 Div. 1 + Div. 2 A Carrot Cakes
- A. Carrot Cakes Codeforce 思维
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) A. Carrot Cakes
- 小白题解 Codeforces 794B Cutting Carrot
- codeforces A. Cakeminator 题解
- codeforces A. TL 题解
- codeforces A. Array题解
- codeforces 150A 题解
- codechef Arranging Cup-cakes题解
- Codeforces A. Double Cola 题解
- codeforces A. IQ test 题解
- codeforces A. Supercentral Point 题解
- codeforces A. k-String 题解
- Codeforces 115A Party 题解
- Codeforces 522A Reposts 题解
- Java基础学习I/O系统---输入流和输出流
- android 开机自启动实现
- pentaho7.0将数据库移植成mysql
- Java NIO之Channel和Buffer学习记录
- 工业大数据漫谈10:开源工业大数据软件简介(下)
- Codeforces 799A Carrot Cakes 题解
- 分布式架构学习之:018--Dubbo集群
- python datetime
- ICMP协议及报文格式
- 爱国者冯军:BAT做大是因为大数据做得好
- 各位大神 php-java-bridge 调用Java类报错什么原因?急!
- ThinkPHP FTP图片上传
- java常用的加密解密方法
- plsql配置