Codeforces Round #370 (Div. 2) C

Source: Internet
Author: User

Description

Memory is now interested in the de-evolution of objects, specifically triangles. He starts with a equilateral triangle of side length x, and he wishes to perform operations to obtain an EQU Ilateral 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-degenerat E Triangle (triangle of positive area). At any moment of time, the length of each side should is integer.

What's the minimum number of seconds required for Memory to obtain the equilateral triangle of side length y ?

Input

The first and only line contains integers x and y (3≤ y < x ≤100 -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 Leng th 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, the Memory can do.

In the second sample test, Memory can does.

In the third sample test, Memory can does:

.

Test instructions: Turn a big equilateral triangle into a small equilateral triangle that takes a few steps

Solution: We consider to be more convenient upside down, first increase one side to the maximum, then add the second edge, in turn, loop to the big equilateral triangle

#include <bits/stdc++.h>using namespace Std;int main () {int n,m;    int a,b,c;    int POS;    int cot=0;    cin>>n>>m;    A=m,b=m,c=m; while (a!=n| | b!=n| |            C!=n) {if (a!=n) {int pos1;            cout<< "A" <<endl;               for (int i=1; i<=n; i++) {//cout<< "B" <<endl;                cout<<a<< "" <<b<< "" <<c<<endl; if ((a+i) +b>c&& (b+c) > (a+i) && (a+i) +c>b&& (a+i) <=n) {PO                   S1=i;                cot++;            }} a=a+pos1;           cot++;           cout<<a<<endl;         Break        cout<<a<< "" <<b<< "" <<c<<endl;      }//cout<<a<< "" <<b<< "" <<c<<endl;        Break            if (b!=n) {int pos2; for (int I=1; i<=n;                i++) {//cout<< "B" <<endl; if ((b+i) +a>c&& (a+c) > (b+i) && (b+i) +c>a&& (b+i) <=n) {//                    B=b+i;                    Pos2=i;                cot++;            }} B=b+pos2;          cot++;        cout<<a<< "" <<b<< "" <<c<<endl;       }//cout<<a<< "" <<b<< "" <<c<<endl;        Break            if (c!=n) {int pos3; for (int i=1; i<=n; i++) {if (c+i) +a>b&&b+ (c+i) >a&&b+a>c+i&&                    (c+i) <=n) {//cout<<i<<endl;                   Pos3=i;                   C=c+i;                cot++;            }} C=pos3+c;         cot++; cout<<a<< "" <<b<< "" &LT;&Lt;c<<endl;       }//break;    cout<<a<< "" <<b<< "<<c<<endl;*/} cout<<cot<<endl; return 0;}

  

Codeforces Round #370 (Div. 2) C

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.