Accepted solution

URI 1160 Solution

Open original problem
Source code

#include <iostream>

#include<iomanip>

using namespace std;

int main()

{

    int T,PA,PB;

    double G1,G2;

    cin>>T;

    while(T>0)

    {

        cin>>PA>>PB>>G1>>G2;

        int ans=0,flag=0;

        while(PA<=PB)

        {

            PA += PA*G1/100;

            PB += PB*G2/100;

            ans++;

            if(ans>100)

            {

                flag=1;

                break;

            }

        }

        if(flag==0)

        {

            cout<<ans<<" anos."<<endl;

        }

        else

        {

            cout<<"Mais de 1 seculo."<<endl;

        }

        T--;

    }

    return 0;

}
Join the discussion

Add your comment