日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Mike and Cellphone

發布時間:2023/12/31 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mike and Cellphone 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

鏈接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=121473#problem/A

Mike and Cellphone ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Time Limit:1000MS?????Memory Limit:262144KB?????64bit IO Format:%I64d & %I64u

While 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:

Together with his old phone, he lost all his contacts and now he can only remember the way his fingers moved when he put some number in. One can formally consider?finger movements?as a sequence of vectors connecting centers of keys pressed consecutively to put in a number. For example, the finger movements for number "586" are the same as finger movements for number "253":

Mike has already put in a number by his "finger memory" and started calling it, so he is now worrying, can he be sure that he is calling the correct number? In other words, is there any other number, that has the same finger movements?

Input

The first line of the input contains the only integer?n?(1?≤?n?≤?9)?— the number of digits in the phone number that Mike put in.

The second line contains the string consisting of?n?digits (characters from '0' to '9') representing the number that Mike put in.

Output

If there is no other phone number with the same finger movements and Mike can be sure he is calling the correct number, print "YES" (without quotes) in the only line.

Otherwise print "NO" (without quotes) in the first line.

Sample Input

Input 3
586 Output NO Input 2
09 Output NO Input 9
123456789 Output YES Input 3
911 Output YES

題意:如果手指行走路線只有一條,就可以確定數值,輸出YES,否者輸出NO。
解析:有兩種方法
1、計算兩點之間的差額,從頭開始,直接尋找。
源代碼: 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 struct node{ 5 int x,y; 6 }a[9]; 7 int main() 8 { 9 node a[]={3,1,0,0,0,1,0,2,1,0,1,1,1,2,2,0,2,1,2,2};//每個數所在的位置 10 int d[4][3]={1,2,3,4,5,6,7,8,9,-1,0,-1};//每個位置上的數 11 int n; 12 int b[10][2]; 13 char c[10]; 14 scanf("%d",&n); 15 int k=0; 16 scanf("%s",c); 17 for(int i=1;i<n;i++) 18 { 19 b[k][0]=a[c[i]-'0'].x-a[c[i-1]-'0'].x; //更改的x值 20 b[k][1]=a[c[i]-'0'].y-a[c[i-1]-'0'].y; //更改的y值 21 k++; 22 } 23 int i,j,t=0; 24 for(i=0;i<=9;i++) 25 { 26 int s=i; 27 for(j=0;j<k;j++) 28 { 29 int xx=a[s].x+b[j][0]; 30 int yy=a[s].y+b[j][1]; 31 if(xx>=0&&xx<4&&yy>=0&&yy<3&&d[xx][yy]>=0) //確定是否可以移動 32 s=d[xx][yy]; //更改第一個點 33 else 34 break; 35 } 36 if(j>=k) //有相同路徑 37 t++; 38 } 39 if(t>1) 40 printf("NO\n"); 41 else 42 printf("YES\n"); 43 return 0; 44 }

2、設上下左右方向的向量分別為U、D、L、R,當不可向該方向移動時對應的字母值為1。例如當操作序列含0時,左右下都不可移動,則L=R=D=0;

? ? ?當所有方向都不可走時,即手勢唯一?

源代碼:

1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int main(){ 5 int n; 6 char s[10000]; 7 while(cin>>n>>s) 8 { 9 int U=0,D=0,L=0,R=0; 10 for(int i=0;i<n;i++) 11 { 12 if(s[i]=='0') 13 D=R=L=1; 14 if(s[i]=='1'||s[i]=='2'||s[i]=='3') 15 U=1;// 16 if(s[i]=='1'||s[i]=='4'||s[i]=='7') 17 L=1;// 18 if(s[i]=='3'||s[i]=='6'||s[i]=='9') 19 R=1;// 20 if(s[i]=='7'||s[i]=='9') 21 D=1;// 22 } 23 if(U==1&&D==1&&R==1&&L==1) 24 cout<<"YES"<<endl; 25 else 26 cout<<"NO"<<endl; 27 } 28 return 0; 29 }

?



轉載于:https://www.cnblogs.com/q-c-y/p/5660107.html

總結

以上是生活随笔為你收集整理的Mike and Cellphone的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 日本福利视频一区 | 高清欧美性猛交xxxx | 中国黄色录像一级片 | 成人亚洲一区二区 | 男女搞黄网站 | 黄色片在哪里看 | 久久97精品久久久久久久不卡 | 亚洲在线观看一区二区 | 天堂999| 在线观看特色大片免费网站 | 东北毛片 | 日韩电影中文字幕 | 麻豆精品视频在线观看 | 人人澡人人澡人人澡 | 久久久ww | 日韩有码视频在线 | 超碰在线公开免费 | 亚洲巨乳av | 快色视频| 国产精选一区 | 国产精品传媒在线 | 快播怡红院 | 麻豆一区二区99久久久久 | 免费三片60分钟 | 日韩乱码人妻无码中文字幕 | 亚洲成人va | 夜夜高潮夜夜爽国产伦精品 | 国产原创中文av | 国产成人在线网站 | 性天堂网 | 椎名空在线播放 | 成人靠逼视频 | 无码人妻一区二区三区免费 | 欧美成人三级在线 | 国产精品一二三四区 | av一区二区在线播放 | 中文字幕女同女同女同 | 国产偷啪| 成人在线小视频 | 大尺度做爰床戏呻吟舒畅 | 国产精品久久久久电影 | 日韩欧美中文一区 | 香蕉久久久久久 | 久久精品日 | 在线观看亚洲免费视频 | 亚洲国产果冻传媒av在线观看 | 久久国产精品久久国产精品 | 麻豆视屏 | www.成人网| 精品黄色在线观看 | 国家队动漫免费观看在线观看晨光 | 免费成人av| 色戒未删节版 | 久久一二区 | 一级黄色短片 | 一级aaa毛片| 欧美日韩a级片 | 日韩在线观看精品 | 国产在线a视频 | 日韩国产专区 | 99蜜桃臀久久久欧美精品网站 | 内射合集对白在线 | 亚洲精品国产精品国自产网站 | 高清国产一区二区三区 | 免费污片在线观看 | 91久久久久久久久久久久久 | 天堂精品一区 | 一级α片免费看刺激高潮视频 | 欧美成人不卡 | 亚洲国产一区视频 | 欧美大片www | 久久99深爱久久99精品 | 五月激情开心网 | 白丝女仆被免费网站 | 欧美黄色免费在线观看 | 中文字幕免费高清 | 美腿丝袜一区二区三区 | 一区二区亚洲视频 | 激情小说av| 国产suv精品一区二区883 | 日韩免费视频观看 | 欧亚av| 伊人久久爱 | 天天操天天操天天操天天 | 精品国产a | 国产资源在线视频 | 亚洲欧美在线不卡 | 污网在线观看 | 亚洲av午夜精品一区二区三区 | 欧美性做爰猛烈叫床潮 | 欧美视频黄 | 亚洲精品一区二区三区四区五区 | 在线视频免费观看 | 精品国产自在精品国产精小说 | 综合网五月 | 日本不卡网 | 91精品国产一区二区三区香蕉 | 深夜视频在线播放 | 欧美精品999 |