CodeForces 712C Memory and De-Evolution (贪心+暴力)
题意:现在有一个长度为 x 的正三角形,每次可以把一条边减小,然后用最少的时间变成长度为 y 的正三角形。
析:一开始,正着想,然后有一个问题,就是第一次减小多少才能最快呢?这个好像并不好确定,然后我就可以倒着想,从一个小三角形变成一个大三角,
那么边长长的越快越好了,剩下的就暴力了。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[4]; int main(){
while(scanf("%d %d", &n, &m) == 2){
a[2] = a[1] = a[0] = m;
int ans = 0;
while(a[0] != n){
a[0] = Min(n, a[1] + a[2] - 1);
sort(a, a+3);
++ans;
}
printf("%d\n", ans);
}
return 0;
}
CodeForces 712C Memory and De-Evolution (贪心+暴力)的更多相关文章
- Codeforces 712C Memory and De-Evolution
		Description Memory is now interested in the de-evolution of objects, specifically triangles. He star ... 
- CodeForces 995B Suit and Tie(贪心,暴力)
		https://codeforces.com/problemset/problem/995/B 题意: 就是通过每次移动相邻的两位数,来使数值相同的数挨在一起,求最少要移动多少次. 思路: 直接从前往 ... 
- Codeforces 990 调和级数路灯贪心暴力 DFS生成树两子树差调水  GCD树连通块暴力
		A 水题 /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) using namespace ... 
- Codeforces 437C  The Child and Toy(贪心)
		题目连接:Codeforces 437C The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> ... 
- Codeforces Round #546 (Div. 2) D 贪心 + 思维
		https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则, ... 
- The 10th Shandong Provincial Collegiate Programming Contest H.Tokens on the Segments(贪心+优先级队列 or 贪心+暴力)
		传送门 •题意 二维平面上有 n 条线段,每条线段坐标为 $(l_i,i),(r_i,i)$: 平面上的每个整点坐标上都可以放置一枚硬币,但是要求任意两枚硬币的横坐标不相同: 问最多有多少条线段可以放 ... 
- codeforces 712C C. Memory and De-Evolution(贪心)
		题目链接:http://codeforces.com/problemset/problem/712/C 题目大意: 给连个值x,y (3 ≤ y < x ≤ 100 000), x,y都为等边三 ... 
- Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
		A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ... 
- Codeforces Round #415 (Div. 2)(A,暴力,B,贪心,排序)
		A. Straight «A» time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ... 
随机推荐
- cocos2d-x改底层之获取UIListView的实际内容大小
			实际项目中UI界面中常常会用到UIListView.大多会在CocoStudio中直接加入这个控件. 可是在使用中发现了一些坑和功能缺乏,然后就看了一下底层的逻辑,发现略微改一下底层就能够满足需求,所 ... 
- 几种自己主动运行js代码的方式
			近期在看jquery,发现他竟然能自己主动运行js代码,于是就查了下.收集了几种经常使用的实现方法 jquery的方法 使用场景:不论什么须要运行的js特效 $(document).ready(fun ... 
- Swift的可选链,类型转换和扩展
			可选链(Optional Chaining) 可选链是一种请求或调用属性.方法,子脚本的过程. 可选性体现于请求或调用的目标当前可能为nil.若不为nil则成功调用.否则返回nil并将链失效. 调用可 ... 
- 2014MadCon厦门分享会-笔记(下)
			32 <如何与百度互动,不知道这些就不要做SEO了>百度站长平台资深产品运营师 曹丽丽(飞鸟) 33 注意百度站长平台的提醒.如果你不留电话,不留其他联系方式,出问题了,百度怎么提醒你呢? ... 
- ConcurrentHashMap源代码解析
			这些天一直在看集合相关的源代码.确实学到了不少东西.这些集合都是息息相关的,学了就停不下来! 学集合就必须要学习锁的知识.学了锁那么并发编程的知识也不能少,都是非常重要的基础知识. jdk1.8的源代 ... 
- OpenStack Live Migration
			About live migration of KVM virtual machines with NFS storage, from Mirantis blog: click this link w ... 
- Redis 脚本及其应用
			参考:http://www.runoob.com/redis/redis-scripting.html Redis 脚本使用 Lua 解释器来执行脚本. Reids 2.6 版本通过内嵌支持 Lua ... 
- swt_table 回车可编辑Esc取消
			package 宿舍管理系统; import java.util.Hashtable; import org.eclipse.swt.SWT; import org.eclipse.swt.custo ... 
- Mybatis中的大于等于和小于等于
			mybatis中可以直接使用>或<:但是不能直接使用>=或<=; 第一种写法(1): 原符号 < <= > >= & ' " 替换符号 ... 
- (linux)container_of()宏
			在学习Linux驱动的过程中,遇到一个宏叫做container_of. 该宏定义在include/linux/kernel.h中,首先来贴出它的代码: /** * container_of - ... 
