UVALive 5797 In Braille
题意:给出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 - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive 6145 Version Controlled IDE(可持久化treap、rope)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- UVALive 6508 Permutation Graphs
Permutation Graphs Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit ...
- UVALive 6500 Boxes
Boxes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pract ...
- UVALive 6948 Jokewithpermutation dfs
题目链接:UVALive 6948 Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...
- 【暑假】[实用数据结构]UVAlive 3135 Argus
UVAlive 3135 Argus Argus Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %l ...
随机推荐
- 面试题:对一个正整数n,算得到1需要的最少操作次数
实现一个函数,对一个正整数n,算得到1需要的最少操作次数.操作规则为:如果n为偶数,将其除以2:如果n为奇数,可以加1或减1:一直处理下去.例子:func(7) = 4,可以证明最少需要4次运算n = ...
- JAVA中SSH面试问题
1.阐述struts2的执行流程. Struts 2框架本身大致可以分为3个部分:核心控制器FilterDispatcher.业务控制器Action和用户实现的企业业务逻辑组件.核心控制器Filter ...
- LightOJ 1317
Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %lluDescription You probab ...
- PreTranslateMessage和TranslateMessage区别(转)
PreTranslateMessage是消息在送给TranslateMessage函数之前被调用的,绝大多数本窗口的消息都要通过这里,比较常用,当需要在MFC之前处理某些消息时,常常要在这里添加代码. ...
- 如何使用SublimeText风格的代码高亮样式 添加Zed Coding(EMMET)插件
因为觉得博客园自带的代码高亮样式很单一,不符合作为前端的我的审美习惯,于是下定决心要想办法折腾出一个方法来应用上另外一套代码高亮样式. 虽然探索的过程是很痛苦的,但最后还是成功了,但也不枉付出的那些努 ...
- [LeetCode]题解(python):026-Remove Duplicates from Sorted Array
题目来源: https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 题意分析: 给定一个排好序的数组,去除重复的数,返回新 ...
- vs2010中iostream.h出错
使用 #include <iostream> using namespace std; 替代 VS2010删除了所有非标准库,保留了C++标准库,iostream.h是以前旧版的库,VS2 ...
- Django : Table 'MyDjango.django_admin_log' doesn't exist
原因: 添加admin之后,没有运行 manage.py syncdb 解决方法: 在命令行中运行manage.py syncdb 即可 运行截图:
- 深入浅出—JAVA(2)
2.类与对象 当你在设计类时,要记得对象是靠类的模型塑造出来的. 1.对象是已知的事物2.对象会执行的动作 对象本身已知的事物被称为 实例变量:它们代表对象的状态.切该类型的每一个对象都会独立的拥有一 ...
- 在Visual Studio 2010中安装iGraph
本安装步骤参考了:http://www.16kan.com/question/detail/182225.html Igraph actually does work with Visual C++ ...