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

Please HELP ME WA 14
Posted by Shohruh_1999 18 Mar 2017 09:29
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>

using namespace std;
int a,b,c,d;
int main()
{
    cin >> a >> b >> c >> d;
    int h = c;
    if(a >= c)
    {
        cout << a;
        return 0;
    }
    while(1)
    {
        if(a == c)
        {
            cout << a;
            return 0;
        }
        a+=b;
        if(c-d >= a) c-=d; else
        {
            if(a > h) cout << h; else
            cout << a;
            return 0;
        }
    }
    return 0;
}