NBUT 1452 Ezreal

  • [1452] Ezreal

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • There are a  LCD (Liquid Crystal Display)  on  Ezreal 's arm. The  LCD  is composed of  liquid crystal , and the  LCD  is  16  lines and  48  rows.  H ow did it work?

    The CPU will send a series of bytes to the LCD. A byte means to eight bits.When the LCD received the byte, it will show a page vertically. And each byte will display from bottom to top.

    For example, 0x01 0x9C 0xED will be shown as below:


    *.*
    ...
    .**
    .**
    .*.
    ..*
    ..*
    .**


    Now give you 64 bytes, you should print it to the LCD from left to right and top to bottom. 32 columns in aBig Row (containing 8 rows).

  • 输入
  • First line contains an integer T (T < 100), means the test case.
    For each case, there are 2 lines which contain 64 hexadecimal numbers, and it is less than 0xff.
  • 输出
  • For each test case, print the LCD's status.
  • 样例输入
  • 1
    01 9C ED DD 1A 2B CF CD C3 00 19 D0 5A 9F 56 13 E5 40 E5 46 E3 BD 4F A4 39 AF D8 2D 6F D4 54 36
    1C B5 3C 24 9F 85 01 75 10 4B A0 00 77 44 77 7D 3B 82 57 47 DD DA DA 61 E5 FD F7 B7 1D E5 D3 A7
    
  • 样例输出
  • *.**.****.*..*.**.*.***.**.**...
    ....***.*...****...**.*..*..*..*
    .***..**.....**.*.**.***.*.*****
    .*******..*.**.......**.*****...
    .*.**.....******.....*..*.*..***
    ..*..*..........*.*.**.***.**..*
    ..**..***..**.*.*****.*...*.***.
    .***..***..*.*..*.*.**.*.**..*..
    .*..****.*..*.***.***..*********
    ....*....*..*.*.****.**...**..**
    ******.*....****..***...******.*
    *.*.*....*.....**...***..*..*...
    ***.*..**...*.***.*.***..****.*.
    .***...*..*.*.***......*****.*.*
    .......*.*..****..*********..**.
    .*..**....*......*..***.****.***
    
  • 提示
  • 来源
  • Monkeyde17

    此题就是一个进制转换的题目,题目可能有点难理解,我是问了别人才看懂的……好吧,不得不承认,人比较笨……Orz……
    稍微解释一下,输入一个十六进制的数,最大不超过0xff,也就是最对占两位,将其换成二进制,二进制占八个字节,如:01 表示为00000001,9C换成二进制是10011100,……
    在输出的时候要从下往上,遇到0就输出“.”,遇到1就输出“*”,每组输如数据有两行,每行32个十六进制数,也就是说,最后要打印出来的是一个16*32的“. *”矩阵......

    #include <algorithm>
    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cmath>
    #include <ctime>
    #include <queue>
    #include <stack>
    #include <set>
    #include <map>
    using namespace std;
    
    typedef long long LL;
    const int maxn = 5e5 + 5;
    const int inf = 0x3f3f3f3f;
    
    char a[2][10][35];
    int p,num;
    
    int main() {
        int t;
        scanf("%d",&t);
        while(t--) {
            for(int k=0; k<2; k++) {
                for(int i=0; i<8; i++) {
                    for(int j=0; j<32; j++)
                        a[k][i][j]='.';
                    a[k][i][32]=0;
                }
                for(int i=0; i<32; i++) {
                    scanf("%x",&p);
                    num=0;
                    while(p) {
                        if(p%2)
                            a[k][num][i]='*';
                        p/=2;
                        num++;
                    }
                }
                for(int i=0; i<8; i++) {
                    for(int j=0; j<32; j++)
                        printf("%c",a[k][i][j]);
                    puts("");
                }
            }
        }
        return 0;
    }
    
    

    这里我还要介绍一种利用 按位取与 操作实现十六进制转二进制的方法,超强大……

    #include <algorithm>
    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cmath>
    #include <ctime>
    #include <queue>
    #include <stack>
    #include <set>
    #include <map>
    using namespace std;
    
    typedef long long LL;
    const int maxn = 5e5 + 5;
    const int inf = 0x3f3f3f3f;
    
    int a[2][32];
    
    int main() {
        int t;
        scanf("%d",&t);
        while(t--) {
            for(int k=0; k<2; k++) {
                for(int i=0; i<32; i++) {
                    cin>>hex>>a[k][i];
                }
                for(int i=0; i<8; i++) {
                    for(int j=0; j<32; j++) {
                        printf("%c",(a[k][j] & (1<<i))==0 ? '.' : '*');
                    }
                    puts("");
                }
            }
        }
        return 0;
    }
    

    如此强大的 ‘按位取与’ 操作,一行代码就将十六进制转换为二进制。。。超神了!!!
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值