【题目链接】: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的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 794B】Cutting Carrot

    [题目链接]:http://codeforces.com/contest/794/problem/B [题意] 给你一个等腰三角形; 它的底边为1; 高为h; 要求你把这个等腰三角形分成n份面积相等的 ...

  3. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  4. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  5. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  6. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  7. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  8. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  9. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

随机推荐

  1. [Sencha ExtJS &amp; Touch] 在Sencha(Extjs/Touch)应用程序中使用plugins(插件)和mixins(混入)

    原文链接:http://blog.csdn.net/lovelyelfpop/article/details/50853591 英文原文:Using Plugins and Mixins in You ...

  2. 【LeetCode OJ 136】Single Number

    题目链接:https://leetcode.com/problems/single-number/ 题目:Given an array of integers, every element appea ...

  3. Selenium实例----12306网站测试

    http://blog.csdn.net/xc5683/article/details/9629827

  4. Resin 优化配置

    1.在resin.conf中的session-config内部添加 <session-max>4096</session-max> <session-timeout> ...

  5. Visio的安装教程

    1.下载地址:https://msdn.itellyou.cn/ 2.输入关键字:Visio,选择想要下载的版本,展开详细信息,并复制 3.(我下载的13) ed2k://|file|cn_visio ...

  6. EOJ 1113 装箱问题

    有一个箱子容量为 V (正整数,0≤V≤20000),同时有 n 个物品(0<n≤30),每个物品有一个体积(正整数).要求从 n 个物品中,任取若干个装入箱内,使箱子的剩余空间为最小. Inp ...

  7. EOJ 2822 内存显示

    一个 int 类型变量或 double 类型变量在连续几个字节的内存中存放.读取数值时,当数值中包含小数点时类型为 double,否则类型为 int.将读入的数值存放在 int 类型变量或 doubl ...

  8. SQL使用总结——集合操作函数

    Oracle中集合操作符专门用于合并多条select 语句的结果,包括:UNION, UNION ALL, INTERSECT, MINUS.当使用集合操作符时,必须确保不同查询的列个数和数据类型匹配 ...

  9. Solr.NET快速入门(三)【高亮显示】

    此功能会"高亮显示"匹配查询的字词(通常使用标记),包括匹配字词周围的文字片段. 要启用高亮显示,请包括HighlightingParameters QueryOptions对象, ...

  10. ubuntu16.04 下载 fabric

    1 Fabric源码下载 我们可以使用Git命令下载源码,也可以使用go get命令,偷懒一点,我们直接用go get命令获取最新的Fabric源码: go get github.com/hyperl ...