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 1877. Bicycle Codes

ac code
Posted by JDBaha 11 Jul 2012 22:29
#include <iostream>

int main()
{
    int k1,k2;
    int count=0;
    int flag=1;


    std::cin>>k1>>k2;

    for(;;)
    {
        if(flag==1)
        {
            if(count==k1)
            {
                std::cout<<"yes";
                return 0;
            }
            count++;
            flag=-flag;
        }
        if(flag==-1)
        {
            if(count==k2)
            {
                std::cout<<"yes";
                return 0;
            }
            count++;
            flag=-flag;
        }
        if(count>k1 && count>k2)
        {
            std::cout<<"no";
            return 0;
        }
    }


}
Re: ac code
Posted by cyan 25 Oct 2012 09:48
a better way:
#include<iostream>
using namespace std;
int main(){
    int lock1,lock2;
    cin>>lock1>>lock2;
    if(lock1%2==0||lock2%2==1){
        cout<<"yes";
    }else{
        cout<<"no";
    }
    return 0;
}
Re: ac code
Posted by zhao kai 3 Nov 2012 07:22
What's the meaning of your code ? and I'm not sure what's the main method to steal the bike by the thief.
Could you mind tell me ?

Edited by author 05.11.2012 22:48
Re: ac code
Posted by tomkus 28 Nov 2012 15:29
you can see that thief is testing even code on night 1, 3, 5...
and odd code on night 2, 4, 6...

So thief can steal the bike if the code is even on night 1, 3, 5...
and odd code on night 2, 4, 6...

Code may be even on night 1,3,5 only if first lock have even code.
Code may be odd on night 2,4,6 only if second lock have odd code.

So you have to check only if first lock have even code or second have odd code.
Re: ac code
Posted by Ksad 12 Feb 2013 17:09
1st. code is correct, but does not meet the requirements of the problem ..
based on the conditions of the problem, such a check should be:
if((a>0 && a <= 9999 && a%2 == 0)||(b>=0 && b <=9999 && b%2 ==1))
        cout << "yes";
    else
    cout << "no";
0000 excluded from the search because the code has been entered., + indicated that a strictly four digit string to the test unchecked ..
verdict .. flawed testing

Edited by author 12.02.2013 17:11
Re: ac code
Posted by kostan3 28 Sep 2013 23:10
#include <iostream>
using namespace std;
int main(){
    int l,b;
    cin>>l>>b;
    l%2==0 || b%2==1 ? cout<<"yes" : cout<<"no";
}

Edited by author 29.09.2013 13:22

Edited by author 29.09.2013 13:22