URAL 1877. Bicycle Codes

来源:互联网 发布:山东网络电视台 编辑:程序博客网 时间:2024/05/17 08:04

1877. Bicycle Codes

Time limit: 0.5 second
Memory limit: 64 MB
Den has two four-digit combination locks for protecting his bicycle from thieves. Every evening he arms the bicycle antitheft alarm and fastens the bicycle to a special stand with one of the locks. Den never uses the same lock two evenings in a row. One night a thief tried to open the lock using the code 0000. The alarm went off and the thief hurried away. The next night the thief decided to try the code 0001, then 0002, and so on in ascending order of the number.
Den never changes the codes of his locks. On the night when the thief came for the first time the bicycle was fastened with the first lock.

Input

The first line contains the combination that opens the first lock and the second line contains the combination that opens the second lock. Both combinations are strings consisting of four digits from 0 to 9.

Output

Output “yes” if the thief will open the lock sooner or later and “no” otherwise.

Samples

inputoutput
00010000
no
00020001
yes



还是水题,看明白题意就很好做了。

大致意思就是一个人有两把锁,设定两个不会换的密码,交替使用。一个小偷从0000开始每天+1来猜密码,最后判断他能否打开锁。

判断两把锁密码的奇偶性就好啦~

#include<cstdio>#include<iostream>using namespace std;int main(){    int a,b;    while(cin>>a>>b)    {        if(a%2==0||b%2==1)            cout<<"yes"<<endl;        else            cout<<"no"<<endl;    }    return 0;}


0 0
原创粉丝点击