UVALive 5797 In Braille
2013-09-02 13:38
274 查看
题目
比赛总结
题意:给出1-9的盲文,每种盲文都是2×3的点阵,有些点是凸起的用*表示,其余的用.表示。要进行两种操作,1 把盲文变成数字,2 把数字变成盲文
解法:按规则模拟。。。。注意读入的每个盲文之间有空格隔开,如果用gets读要消息空格和换行
比赛总结
题意:给出1-9的盲文,每种盲文都是2×3的点阵,有些点是凸起的用*表示,其余的用.表示。要进行两种操作,1 把盲文变成数字,2 把数字变成盲文
解法:按规则模拟。。。。注意读入的每个盲文之间有空格隔开,如果用gets读要消息空格和换行
//time 3ms #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> const int MAXN = 5005; using namespace std; char str[10][10]={"011100","100000","101000","110000","110100","100100","111000","111100","101100","011000"}; char st[MAXN][10]; int main() { //freopen("/home/moor/Code/input","r",stdin); int n; char a[MAXN],op[5]; while(scanf("%d",&n)&&n) { scanf("%s",op); if(op[0]=='S') { scanf("%s",a); for(int i = 0; i < 3; i++) { for(int j = 0; a[j]; j++) { int p=a[j]-'0'; if(str[p][i*2]=='1') printf("*"); else printf("."); if(str[p][i*2+1]=='1') printf("*"); else printf("."); if(j!=(int)strlen(a)-1) printf(" "); } printf("\n"); } } else { for(int i = 0; i < 3; i++) { a[0]='\0'; while(a[0]=='\0') gets(a); for(int j = 0,k=0; a[j]; j+=3,k++) { if(a[j]=='*') st[k][i*2]='1'; else st[k][i*2]='0'; if(a[j+1]=='*') st[k][i*2+1]='1'; else st[k][i*2+1]='0'; } } for(int i = 0; i < n; i++) { st[i][6]='\0'; for(int j = 0; j < 10; j++) { if(strcmp(str[j],st[i])==0) { printf("%d",j); break; } } } printf("\n"); } } return 0; }
相关文章推荐
- UVALive 5797 In Braille
- UVALive 5797解题报告
- UVALive - 3635 Pie
- UVALive 3907 (LA 3907) Puzzle AC自动机 + 搜索DP 记录路径
- UVaLive 5713 秦始皇修路(O(n^2)预处理MST的maxcost数组)
- UVA-10716 Evil Straw Warts Live(贪心+模拟)
- uvalive 3983(dp)
- uvalive4094
- UVALive 7752 模拟
- [nim博弈扩展 sg函数] UVALive 3668 A Funny Stone Game
- UVALive 2678 大于s的最短子序列和
- Corporative Network +uvalive+并查集
- UVALive 6912
- UVALive3713_Astronauts
- UVALive - 5713 最小生成树
- UVALive 6838 Flipping Parentheses (线段树)
- UVALive 6933 Virus synthesis(回文树)
- UVALive 6837 (最小生成树)
- UVALive 7041 The Problem to Slow Down You(回文树)
- UVaLive 4043 Ants (最佳完美匹配)