【瞎搞】HDU 3257 Hello World!

题目只说了输入16进制的数 和输出6×n-1个行

则知一个字母由5竖 7个带#号或者空格组成

发现输入的十六进制数转化为二进制 倒过来正好对应一个字母的一竖 0对应着空格 1对应着# 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <math.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
//#define LOCAL_TEST
typedef long long LL;
typedef pair<int, int> pi;
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define N 120000

int ans[85][8][8];
int main()
{
#ifdef LOCAL_TEST
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int t, ca=1;
    scanf("%d", &t);
    while(t--)
    {
        int n, a;
        scanf("%d", &n);
        memset(ans, 0, sizeof(ans));
        for(int i=0;i<n;i++)
            for(int j=0;j<5;j++)
            {
                scanf("%x", &a);//输入十六进制
                int d=0;
                while(a)//转化为二进制
                {
                    ans[i][j][d++]=a%2;
                    a/=2;
                }
            }
        printf("Case %d:\n\n", ca++);//中间要空一行
        for(int i=0;i<7;i++)
        {
           for(int j=0;j<5*n;j++)
           {
                if(j!=0 && j%5==0)
                    printf(" ");
                if(ans[j/5][j%5][i]==0)
                    printf(" ");
                else
                    printf("#");

            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


posted @ 2014-08-17 18:27  kewowlo  阅读(159)  评论(0编辑  收藏  举报