Codeforces Round #361 (Div. 2)A. Mike and Cellphone
来源:互联网 发布:淘宝 白酒 知乎 编辑:程序博客网 时间:2024/06/05 23:45
链接:http://codeforces.com/contest/689/problem/A
题意:有一个人手机丢了,他只记得手机密码的按键手势,但是不记得具体数字了,问这个按键手势是否唯一。
分析:标记下每一个点的转移方向,枚举0~9所有的起点看有多少种是合法的手势。
代码:
#include<map>#include<set>#include<cmath>#include<queue>#include<bitset>#include<math.h>#include<cstdio>#include<vector>#include<string>#include<cstring>#include<iostream>#include<algorithm>#pragma comment(linker, "/STACK:102400000,102400000")using namespace std;const int N=100010;const int MAX=1000000100;const int mod=100000000;const int MOD1=1000000007;const int MOD2=1000000009;const double EPS=0.00000001;typedef long long ll;const ll MOD=1000000007;const int INF=1000000010;const double pi=acos(-1.0);typedef double db;typedef unsigned long long ull;char s[20];int g[10][2]={4,2,1,1,1,2,1,3,2,1,2,2,2,3,3,1,3,2,3,3};int f[15][2];int out(int x,int y) { if (x==4&&y==2) return 0; if (x>0&&x<4&&y>0&&y<4) return 0; return 1;}int pd(int a,int len) { int i,x=g[a][0],y=g[a][1]; for (i=1;i<len;i++) { x+=f[i][0];y+=f[i][1]; if (out(x,y)) return 0; } return 1;}int main(){ int i,n,sum=0; scanf("%d", &n); scanf("%s", s); for (i=1;i<n;i++) { f[i][0]=g[s[i]-'0'][0]-g[s[i-1]-'0'][0]; f[i][1]=g[s[i]-'0'][1]-g[s[i-1]-'0'][1]; } for (i=0;i<10;i++) sum+=pd(i,n); if (sum==1) printf("YES\n"); else printf("NO\n"); return 0;}
0 0
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone
- Codeforces Round #361 (Div. 2)A. Mike and Cellphone
- Codeforces Round #361 (Div. 2) A. Mike and Cellphone ( 模拟 )
- Codeforces Round #361 (Div.2) - A. Mike and Cellphone
- Codeforces Round #361 (Div. 2) 689A Mike and Cellphone
- Codeforces Round #361 (Div. 2) -- A. Mike and Cellphone (思路题目)
- CodeForces 689A Mike and Cellphone
- codeforces 689A Mike and Cellphone(模拟)
- Codeforces-689A-Mike and Cellphone
- Codeforces Round #305 (Div. 2) A. Mike and Fax
- Codeforces Round #305 (Div. 2), problem: (A) Mike and Fax
- Codeforces Round #305 (Div. 2)--A. Mike and Fax
- Codeforces Round #305 (Div. 2)A. Mike and Fax
- Codeforces Round #410 (Div. 2)-A. Mike and palindrome-思维
- Codeforces Round #410 (Div.2) A.Mike and palindrome-模拟
- A. Mike and Cellphone(cf#361)
- 集成mob的SMSsdk和shareSDK
- 关于 Java 中 try、finally 语句块的分析
- 博客带小星星
- 软回车和硬回车
- HTTP——10 Status Code Definitions
- Codeforces Round #361 (Div. 2)A. Mike and Cellphone
- Linux Shell 中的反引号,单引号,双引号
- 稀疏编码最优化解法
- 【数据结构】二叉搜索树
- hdu 4387 双连通分量 求权值最小的桥
- C/C++跨平台INI文件解析库:iniparser
- IOS -iphone设备信息读取
- 深入理解Java虚拟机-自动内存管理机制
- ioc 控制反转