【codeforces 799A】Carrot Cakes
【题目链接】:http://codeforces.com/contest/799/problem/A
【题意】
你有一个烤炉;
每t秒能同时烤出k个蛋糕;
你可以在第一个烤炉在烤的时候;同时花费d秒建造另外一个相同的烤炉;
也是t秒烤出k个蛋糕;
问你是否造两个烤炉一起烤更快;
【题解】
先算出一个烤炉要花多长时间;
((n-1)/k +1)*t
然后枚举时间i;
如果i是k的倍数,则tot+=k,如果(i-d)>0且(i-d)是k的倍数则tot也能递增k;
找到第一个tot大于等于n的i就好;
这就是两个烤炉所需要花费的时间.
比较一下是不是两个烤炉更优就好.
(另外一个思路是,枚举两个烤炉分别烤了多少次,取两个烤炉花费时间的最大值作为时间,如果总蛋糕数大于等于n则符合,取最小的时间作为t2就好)
【Number Of WA】
0
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 110;
int n,t,k,d,t1,t2;
int main()
{
//freopen("F:\\rush.txt","r",stdin);
ios::sync_with_stdio(false),cin.tie(0);//scanf,puts,printf not use
//init??????
cin >> n >> t >> k >> d;
t1 = ((n-1)/k + 1)*t;
int tot = 0;
for (int i = 1;;i++)
{
if (i%t==0)
{
tot+=k;
}
if (i>d)
{
if ((i-d)%t==0)
tot+=k;
}
if (tot>=n)
{
t2 = i;
break;
}
}
if (t2<t1)
cout<<"YES"<<endl;
else
cout <<"NO"<<endl;
return 0;
}
【codeforces 799A】Carrot Cakes的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 794B】Cutting Carrot
[题目链接]:http://codeforces.com/contest/794/problem/B [题意] 给你一个等腰三角形; 它的底边为1; 高为h; 要求你把这个等腰三角形分成n份面积相等的 ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
- 【Codeforces 670C】 Cinema
[题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...
随机推荐
- 热修复JSPatch之实战教程
接上篇<热修复JSPatch之接口设计>,在这篇文章主要给大家讲述一下怎样高速具备热修复能力,当然了假设有人有志于把JSPatch系统的学习,甚至用JSPatch进行开发的.就没有必要 ...
- VMware workstation虚拟机不能联网解决方法
以备后用. 第一步:先设置VMware的编辑——虚拟网络编辑器,启用VMnet8,NAT模式,如下图所示. 其实就是VMware默认的设置,无须更改,如果不小心改了,点击还原默认设置. 第二步:虚拟机 ...
- bootstrap搜索样式
<div class="container"> <div class="input-group"> <input type=&qu ...
- 【SDOI 2010】 古代猪文
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1951 [算法] 欧拉定理+中国剩余定理 + lucas定理 [代码] #includ ...
- MSDN性能分析相关网站收集
Visual Studio 性能分析初学者指南 | Microsoft Docshttps://docs.microsoft.com/zh-cn/visualstudio/profiling/begi ...
- maven nexus memory optimization
#链接地址:https://help.sonatype.com/repomanager3/system-requirements#filehandles While starting Nexus I ...
- LeetCode 287. Find the Duplicate Number (python 判断环,时间复杂度O(n))
LeetCode 287. Find the Duplicate Number 暴力解法 时间 O(nlog(n)),空间O(n),按题目中Note"只用O(1)的空间",照理是过 ...
- [ Database ] [ SQL Server ] SQL Server 很多不允許的操作解決方法
說明可參考 https://blog.miniasp.com/post/2012/10/26/SQL-Server-Management-Studio-Prevent-saving-changes-t ...
- SQL触发器 inset自学经验
本人建立了一个特价汇网站,想要记录每个商品的点击量和整个网站的访问量,于是就想用sql 触发器来实现 drop trigger tgr_cg_records_update_column create ...
- HDFS开发中的一些问题(逐步补充)
1.windows操作系统下运行时报:Failed to locate the winutils binary in the hadoop binary path java.io.IOExcept ...