ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1607. Taxi

answer c++
Posted by Misha Vasylyshyn 21 Jan 2017 01:08
Очень хитрая задача, так как в условии не сказано или а меньше с или с меньше а поэтому нужно рассматривать 2 варианта.
Вот правильный код:
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin >> a >> b >> c >> d;
    if( a <= c)
    {
        while(a <= c)
    {
        if( a + b <= c)
        {
           a = a + b;
           e = a;
        }
        else {e = c;break;}

        if( c -d >= a)
        {
            c = c - d;
            e = c;
        }
        else {e = a;break;}
    }
    cout << e << endl;
    }
    else
        cout << a << endl;
    return 0;
}
Re: answer c++
Posted by death 25 Oct 2023 21:04
del

Edited by author 25.10.2023 21:07