【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 ...
随机推荐
- [Angular] Freshness Caching Policy - Network First, Cache Last
In some cases, you want to get fresh data instead of cache data to the screen, such as stock applica ...
- 关于IFeatureSelection的SelectFeatures方法
近期做项目时用到IFeatureLayer as IFeatureSelection,然后使用IFeatureSelection.SelectFeatures方法.可是得到的IFeatureSelec ...
- 黑马day07 登录注冊案例(一)
简单介绍:依据三层架构的思想设计本案例. 1.搭建好开发环境 准备好须要的包和模拟数据库配置文件users.xml -->cn.itheima.dao -->cn.itheima.serv ...
- 【JNI探索之路系列】之七:JNI要点总结
作者:郭嘉 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells github:https://github.com/AllenWells ...
- android 构建GPS Provide步骤及信息
构建GPS Provide步骤及信息 1. 用GPS2GoogleEarth录制KML文件 2. KML文件 2.1 经纬度解析 <LineString> <coordina ...
- c++11 实现半同步半异步线程池
感受: 随着深入学习,现代c++给我带来越来越多的惊喜- c++真的变强大了. 半同步半异步线程池: 事实上非常好理解.分为三层 同步层:通过IO复用或者其它多线程多进程等不断的将待处理事件加入到队列 ...
- QString够绕的,分为存储(编译器)和解码(运行期),还有VS编译器的自作主张,还有QT5的变化
多读几篇,每篇取几句精华加深我对QString的理解. ------------------------------------------------------------------ QStri ...
- C#中大批量导入数据SqlBulkCopy
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...
- 判断输入的值是否为Double
using System; using System.Collections.Generic; using System.Text; namespace TDRFactory { public cla ...
- html中map标签和area标签的应用
map标签的用途:是与img标签绑定使用的,常被用来赋予给客户端图像某处区域特殊的含义,点击该区域可跳转到新的文档. 因为map标签是与img标签绑定使用的,所以我们需要给map标签添加ID和name ...