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 ...
随机推荐
- php命名空间及和autoload结合使用问题。
在讨论如何使用命名空间之前,必须了解 PHP 是如何知道要使用哪一个命名空间中的元素的.可以将 PHP 命名空间与文件系统作一个简单的类比.在文件系统中访问一个文件有三种方式: 相对文件名形式如foo ...
- Never-build package 'XXXX' requires always-build package 'EhLib70'
控件包使用了DbGridEh.Requies也加入了ehlib70.dcp就是编译时不通过,提示: Never-build package 'XXXX' requires a ...
- golang语法学习(一):变量,常量以及数据类型
学习一门新的语言肯定是要从他的主要的语法開始,语法构成了整个程序设计的基础,从语法中我们也能够看到这门语言的一些特性.可是话说回来.语法这东西,不同的语言大同小异,所以这也对语法的记忆造成了一定的难度 ...
- POJ 2695 The Pilots Brothers' refrigerator(神奇的规律)
转载请注明出处:http://blog.csdn.net/a1dark 分析:如果想要将一个“+”翻转成“-”,那么必然会把对应的行和列上的所有点翻转一次.由于一个点翻偶数次就相当于不翻转.所以我需要 ...
- JavaScript 高级程序设计(第3版)笔记——chapter7:函数表达式
一.函数表达式的语法形式 匿名函数 var functionName = function(arg0, arg1, arg2) { //函数体 } 二.函数表达式没有函数提升 var a = 1; i ...
- Quiz 6b Question 7————An Introduction to Interactive Programming in Python
Question 7 Convert the following English description into code. Initialize n to be 1000. Initiali ...
- java覆写equals方法
何时需要重写equals() 当一个类有自己特有的“逻辑相等”概念(不同于对象身份的概念). object规范规定,如果要重写equals(),也要重写hashcode() 如何覆写equals() ...
- UrlEncode编码/UrlDecode解码
public class encode { public static void main(String[] args) throws UnsupportedEncodingException ...
- 《JavaScript权威指南》拾遗(下)
一.类和原型 1.在JavaScript中,类的实现是基于原型继承机制的,如果两个实例都是从同一个原型对象中继承了属性,则它们是同一个类的实例. 2.原型对象是类的唯一 ...
- Spring AOP报错
八月 01, 2016 10:08:48 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRe ...