题目链接:http://codeforces.com/problemset/problem/712/C

题意:

  给你两个值 a 和 b (a > b), 代表这里有两个等边三角形, 边长分别为 a 和 b, 你可以对边长为 a 的三角形进行变换, 每次变化你可以选择一条边, 并为其重新指定一个长度, 当然变换完成后还能组成一个三角形.问最少经过多少次变换可以把等边三角形的三边长度从 a 变换到 b.

思路:

  题目中的意思时从大的三角形变换到小的三角形,这里可以换一种方式,即 “最少经过多少次变换可以把边长从 b 变到 a”, 可以想到, 这里需要做的就是让三条边在变化范围中尽可能的接近 a. 即对于边长 (ba, bb, bc), 第一条边长的长度变化范围为 ba < bb + bc , 如果这里 bb + b<= a, 那么为了让 ba 更接近 a, 就可以让 ba 取 bb + b - 1,如果 bb + b< a, 则 ba 直接取 a 就好了; 然后对于第二条边 bb 做出同样的变换,然后已知迭代下去, 直到 ba = b = bc = a, 结束变换就好了.

代码:

 1 #include <bits/stdc++.h>
 2
 3 using namespace std;
 4 typedef long long LL;
 5
 6 const int MAXN = 100000;
 7 int st, ed, ans = 0;
 8
 9 void solv(int a, int b, int c) {
10     if(a == b && a == c && a == st) return ;
11     ans++;
12     if(ans % 3 == 1) st < b + c ? a = st : a = b + c - 1;//让第一条边尽可能接近 st
13     else if(ans % 3 == 2) st < a + c ? b = st : b = a + c - 1;
14     else st < a + b ? c = st : c = a + b - 1;
15     solv(a, b, c);
16 }
17
18 int main() {
19     ios_base::sync_with_stdio(); cin.tie();
20     cin >> st >> ed;
21     solv(ed, ed, ed);
22     cout << ans << endl;
23     return 0;
24 }

 

转载于:https://www.cnblogs.com/Ash-ly/p/5861440.html

Codeforces 712C. Memory and De-Evolution相关推荐

  1. Codeforces 712E Memory and Casinos

    Description There are n casinos lined in a row. If Memory plays at casino \(i\), he has probability ...

  2. Codeforces 712A. Memory and Crow

    题目链接:http://codeforces.com/problemset/problem/712/A 题意: 有两个序列 ai 和 bi, 长度都为 n, 对于序列 ai 满足 ai = bi - ...

  3. Codeforces 712A Memory and Crow

    参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6374955.html [题目链接]  A. Memory and Crow time limit ...

  4. codeforces A. Memory and Crow

    A. Memory and Crow time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. codeforces 712 Memory and De-Evolution

    2019-05-19 13:25:37 加油,加油,坚持,坚持!!! 一定要逆推,才可以是最少的次数 更好的方法: https://www.cnblogs.com/ECJTUACM-873284962 ...

  6. ECJTUACM16 Winter vacation training #4 题解源码

    https://vjudge.net/contest/149692#overview 这周一VJ比赛,题解&源码已完成! A.................................. ...

  7. c/c++动态检测内存错误利器 - ASan

    ASan,即Address Sanitizer,是一个适用于c/c++的动态内存错误检测器,它由一个编译器检测模块(LLVM pass)和一个替换malloc函数的运行时库组成,在性能及检测内存错误方 ...

  8. 耶鲁大学开放课程:《心理学导论》

    课程类型:心理学 课程介绍: 你的梦应该如何解析?男人和女人在两性需求的性质和程度是否不同?猩猩能否学习手语?为什么我们不能 胳肢自己?本课程试图回答这些以及其他诸如此类的问题,并提供了思想和行为科学 ...

  9. 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 ...

最新文章

  1. 摊牌了,我靠它们成功实现了AI零基础入门到进阶!
  2. (论文阅读笔记1)Collaborative Metric Learning(二)(WWW2017)
  3. wps html编辑表格,手机wps中怎么编辑表格图文教程
  4. asp.net dev xtraReporting(一)静态页面
  5. ]flume高并发优化——(1)load_balance
  6. ps批量修改名片文字_教你用PS设计漂亮的名片
  7. UCF,基于用户的协同过滤算法
  8. 京东2022双11预售期,商家该做些什么?
  9. vue项目接入eslint、prettier、husky+lint-staged
  10. linux打开python3_号外:RIDE 可以在 linux+python3 的环境中运行啦!
  11. canva五角星空html,使用canvas绘制一个五角星
  12. mysql计算三角形斜边_MySQL 5.7新特性之Generated Column(函数索引)
  13. fatal: unable to access github.com schannel failed to receive handshake, SSL/TLS connection failed
  14. 英雄联盟(LOL)外挂原理(仅供学术交流)
  15. oracle网页客户端工具
  16. 【二分法】计蒜客习题 切割钢管
  17. 是否允许应用获取设备信息_iOS 14 隐私保护:管理和控制共享的位置信息
  18. 动态规划DP模板题汇总
  19. react native 集成腾讯语音合成TTS(android)
  20. 基于MATLAB的神经网络训练的车牌识别系统

热门文章

  1. ES6_入门(1)_let命令
  2. Latex应用和资源
  3. android 从文件制定位置读取数据
  4. android 修改包名
  5. Android Volley完全解析(四),带你从源码的角度理解Volley
  6. 如何高效维持网络长连接
  7. This version of the rendering library is more recent than your version of IntelliJ IDEA.
  8. 一个循环、一个变量打印乘法口诀
  9. 1041 考试座位号
  10. Django的静态资源