您的位置:首页 > 其它

codeforces 361 A - Mike and Cellphone

2016-07-12 20:30 399 查看
题目链接:http://codeforces.com/contest/689/problem/ADescriptionWhile swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way:
#include<iostream>
#include<cstdio>
using namespace std;
char a[12];
int n;
int xx()
{
int a1,b,c,d;
a1=1;
b=1;
c=1;
d=1;
for(int i=0; i<n; i++)
{

if(a[i]=='1'||a[i]=='4'||a[i]=='7'||a[i]=='0') a1=0;
if(a[i]=='3'||a[i]=='6'||a[i]=='9'||a[i]=='0') b=0;
if(a[i]=='1'||a[i]=='2'||a[i]=='3') c=0;
if(a[i]=='7'||a[i]=='9'||a[i]=='0') d=0;
}
if(a1||b||c||d) return 0;
else return 1;
}
int main()
{
while(cin>>n)
{
cin>>a;
if(xx()) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
View Code

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: