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

can u help me? here is my code
Posted by beautiful 20 Mar 2008 11:30
#include<iostream>
using namespace std;

int main(){
    int petr,a,taxi,b;
    int temp;

    while(cin>>petr>>a>>taxi>>b){
        if(petr>=taxi)cout<<petr<<endl;

        else{
            temp=taxi-petr;
            if(a<=b){
                while(temp>b){
                    petr+=a,taxi-=b;
                    temp=taxi-petr;
                }
                cout<<petr+a<<endl;
            }
            else{
                while(temp>a){
                    petr+=a,taxi-=b;
                    temp=taxi-petr;
                }
                cout<<taxi<<endl;
            }
        }
    }
}

i pass all the test that the discuss give
but i still get wa at #4
could u give me some new test?
Re: can u help me? here is my code
Posted by beautiful 20 Mar 2008 11:38
if(a<=b)
---> if(a<b)

but i still get wa at #13
Re: can u help me? here is my code
Posted by Fox 20 Mar 2008 17:55
for exanmple try test
1000 2 2000 3

the right answer is 1400
but your prog output 1402

or try this
1 2 12 3

right is 6
but yours is 7

Edited by author 20.03.2008 17:57
Re: can u help me? here is my code
Posted by beautiful 21 Mar 2008 16:12
Thank u very much!
Re: can u help me? here is my code
Posted by luc1kJke_(It-Team) 19 Sep 2009 02:01
thanks for 2nd test, it really helpfull)
Re: can u help me? here is my code
Posted by Ealham Al Musabbir 19 Jun 2015 01:35
Thanks a lot...
^_^
Re: can u help me? here is my code
Posted by ِAbdalla 12 Jul 2019 02:19

// solve
#include <iostream>
using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a< c)
    {
        if(a+b > c)
        {
            a=c;
            break;
        }
        a= a+b;
        if(c <= a)
        {
         break;
        }
        c = c-d;
    }

    cout<<a<<endl;
    return 0;
}