Codeforces Round #370 (Div. 2)C. Memory and De-Evolution 贪心
地址:http://codeforces.com/problemset/problem/712/C
题目:
2 seconds
256 megabytes
standard input
standard output
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such that it remains a non-degenerate triangle (triangle of positive area). At any moment of time, the length of each side should be integer.
What is the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y?
The first and only line contains two integers x and y (3 ≤ y < x ≤ 100 000) — the starting and ending equilateral triangle side lengths respectively.
Print a single integer — the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y if he starts with the equilateral triangle of side length x.
6 3
4
8 5
3
22 4
6
In the first sample test, Memory starts with an equilateral triangle of side length 6 and wants one of side length 3. Denote a triangle with sides a, b, and c as (a, b, c). Then, Memory can do .
In the second sample test, Memory can do .
In the third sample test, Memory can do:
.
思路:倒着贪心就好,每次把最小的边变换成最大的。。
代码:
#include <bits/stdc++.h> using namespace std; #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-;
const double pi = acos(-1.0);
const int K = 1e6 + ;
int a[];
int main(void)
{
int ans=,st,se;
cin>>st>>se;
a[]=a[]=a[]=se;
while()
{
sort(a+,a++);
if(a[]<st)
a[]=min(a[]+a[]-,st);
else
break;
//printf("%d:%d %d %d\n",ans+1,a[1],a[2],a[3]);
ans++;
}
cout<<ans<<endl;
return ;
}
Codeforces Round #370 (Div. 2)C. Memory and De-Evolution 贪心的更多相关文章
- Codeforces Round #370 (Div. 2) E. Memory and Casinos 线段树
E. Memory and Casinos 题目连接: http://codeforces.com/contest/712/problem/E Description There are n casi ...
- Codeforces Round #370 (Div. 2)B. Memory and Trident
地址:http://codeforces.com/problemset/problem/712/B 题目: B. Memory and Trident time limit per test 2 se ...
- Codeforces Round #370 (Div. 2) D. Memory and Scores 动态规划
D. Memory and Scores 题目连接: http://codeforces.com/contest/712/problem/D Description Memory and his fr ...
- Codeforces Round #370 (Div. 2) C. Memory and De-Evolution 水题
C. Memory and De-Evolution 题目连接: http://codeforces.com/contest/712/problem/C Description Memory is n ...
- Codeforces Round #370 (Div. 2) B. Memory and Trident 水题
B. Memory and Trident 题目连接: http://codeforces.com/contest/712/problem/B Description Memory is perfor ...
- Codeforces Round #370 (Div. 2) A. Memory and Crow 水题
A. Memory and Crow 题目连接: http://codeforces.com/contest/712/problem/A Description There are n integer ...
- Codeforces Round #370 (Div. 2) E. Memory and Casinos (数学&&概率&&线段树)
题目链接: http://codeforces.com/contest/712/problem/E 题目大意: 一条直线上有n格,在第i格有pi的可能性向右走一格,1-pi的可能性向左走一格,有2中操 ...
- Codeforces Round #370 (Div. 2) D. Memory and Scores DP
D. Memory and Scores Memory and his friend Lexa are competing to get higher score in one popular c ...
- Codeforces Round #370 (Div. 2) A B C 水 模拟 贪心
A. Memory and Crow time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- Spark集群 + Akka + Kafka + Scala 开发(4) : 开发一个Kafka + Spark的应用
前言 在Spark集群 + Akka + Kafka + Scala 开发(1) : 配置开发环境中,我们已经部署好了一个Spark的开发环境. 在Spark集群 + Akka + Kafka + S ...
- ASP.NET Web API获取Model元数据
using System; using System.Web.Http; using Common; namespace ConsoleApp { internal class Program { p ...
- web安全——系统(Linux)
简介 最小(少)原则,是安全的重要原则.最小的权限,最小的用户,最少的服务,最少的进程,是最安全的. 系统安全包括:文件系统保护.用户管理安全.进程的保护以及日志的管理. 场景 确保服务最少,每个都是 ...
- playframework文档未提及,但你能做的事
这里记录一些play!框架的文档未提及,但是可以做的一些事playframe版本1.1 1.application.conf文件可以拆分可以把application.conf文件拆成多个,需要在app ...
- docker入门指南(转载)
原文: http://bg.biedalian.com/2014/11/20/docker-start.html 关于 docker 今天云平台的同事提到, 现在的运维就是恶性循环, 因为大家都在申请 ...
- Failed to upgrade AX 2012 R3 Retail channel database from CU9 to CU11 if SQL Server version was lower than 2012
I tried to upgrade AX 2012 R3 Retail channel database from CU9 to CU11 for client. after generated n ...
- ArcGIS补丁包下载
http://zhihu.esrichina.com.cn/?/feature/patchdownload
- 汇编语言--寄存器(cpu工作原理)
本文地址:http://www.cnblogs.com/archimedes/p/assembly-register.html,转载请注明源地址. 本文主要将介绍的是8086 CPU中的寄存器, 寄存 ...
- iOS开发基础框架
---恢复内容开始--- //appdelegate //// AppDelegate.m// iOS开发架构//// Copyright © 2016年 Chason. All rights ...
- iOS开发之网络编程--3、NSURLSessionDataTask实现文件下载(离线断点续传下载)
前言:使用NSURLSessionDownloadTask满足不这个需要离线断点续传的下载需求,所以这里就需要使用NSURLSessionDataTask的代理方法来处理下载大文件,并且实现离线断点续 ...