UVA 573 The Snail Solution

Solve in C++:

///**********ALLAH IS ALMIGHTY************///
     ///AH Tonmoy
    ///Department of CSE,23rd batch
    ///Islamic University,Bangladesh

#include<iostream>
using namespace std;
int main()
{
    double h,u,d,f;
    while(cin >> h >> u >> d >> f && h != 0)
    {
        int i = 0;
        double ht = 0.0;
        f=(f*u)/100;
        while(1)
        {
            i++;
            if(u>0)
            {
                ht=ht+u;
                u=u-f;
            }
            if(ht>h)
                break;
            ht=ht-d;
            if(ht<0)
                break;
        }
        if(ht<0)
            cout << "failure on day " << i << endl;
        else if(ht>h)
            cout << "success on day " << i << endl;
    }
    return 0;
}

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.