题解:P13829 【MX-X18-T1】「FAOI-R6」520
思路
如果你和我一样有小键盘,那就好办了。
首先,我们先打张表,表示小键盘上上下下左左右右打来打去得到的字符串:
string a[N]={"0147","7410","/8520","0258/","*963.",".369*","+-","-+","789+","+987","456+","+654","123","321","0.",".0","/*-","-*/"};然后通过 find 函数判断输入是不是其子串即可。
代码
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
string str;
string a[N]={"0147","7410","/8520","0258/","*963.",".369*","+-","-+","789+","+987","456+","+654","123","321","0.",".0","/*-","-*/"};
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>str;
for(int i=0;i<18;i++){
string s=a[i];
if(s.find(str)!=-1){
cout<<"Yes"<<endl;
return 0;
}
}
cout<<"No"<<endl;
return 0;
}