国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 古田县| 平陆县| 丰宁| 两当县| 长泰县| 井陉县| 阿拉善盟| 八宿县| 惠水县| 云梦县| 磴口县| 玛多县| 屏东市| 郧西县| 阿克苏市| 隆回县| 荣成市| 中阳县| 敦煌市| 普兰县| 济宁市| 土默特右旗| 牟定县| 通辽市| 天等县| 凤凰县| 庆云县| 乐陵市| 黄冈市| 清徐县| 陇南市| 陵川县| 双牌县| 南皮县| 太仆寺旗| 同仁县| 阳东县| 黄大仙区| 玉环县| 山阴县| 嘉峪关市|