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

HERE'S MY CODE, PLEASE HELP, WHAT'S WRONG? (WA#11)
Posted by Jose Daniel Mendez Ceron 6 Mar 2008 05:43
#include <stdio.h>
int calculate(int a,int b,int c,int d);
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%d",calculate(a,b,c,d));
    return 0;
}
int calculate(int a,int b,int c,int d)
{
    if(a == c || a > c )
        return a;
    else if(a + b > c)
        return c;
    else if(((a+b) > (c-d))&& b < d)
        return c;
    else if( (a+b)==(c-d))
        return (a+b);
    else
        while(1){
            a+=b;
            c-=d;
        if( a>=c )
            return a;
        if( ((a+b) >= (c-d)) && ( b>=d))
            return c;
        }
}