国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【Codeforces 712 C. Memory and De-Evolution】+ 貪心

2019-11-08 02:24:31
字體:
來源:轉載
供稿:網友

C. Memory and De-Evolution time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard 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?

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

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

Examples input 6 3 output 4 input 8 5 output 3 input 22 4 output 6 Note 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:

把y變為x,每次盡可能的把最小邊變的盡可能的大,即 x1 = x2 + x3 -1,都大于等于x?

AC代碼:

#include<cstdio>#include<algorithm>using namespace std;int a[3];int main(){ int x,y,num = 0,n = 0; scanf("%d %d",&x,&y); a[0] = a[1] = a[2] = y; while(a[0] < x || a[1] < x || a[2] < x) a[n % 3] = a[(n + 1) % 3] + a[(n + 2) % 3] - 1,n++; printf("%d/n",n); return 0;}

.


上一篇:位域

下一篇:codeforces 607B dp

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 梁河县| 鄯善县| 堆龙德庆县| 绍兴市| 南乐县| 天长市| 呼伦贝尔市| 沐川县| 楚雄市| 略阳县| 龙山县| 鄢陵县| 剑河县| 阿合奇县| 甘南县| 朔州市| 文水县| 佛冈县| 韶关市| 循化| 宝鸡市| 车致| 鹤庆县| 吴川市| 南充市| 绥化市| 平远县| 图们市| 桐梓县| 苏尼特右旗| 水城县| 奇台县| 塔城市| 台前县| 怀仁县| 栾川县| 石渠县| 高邑县| 仙游县| 枝江市| 枝江市|