HDU 3257 Hello world! (Bitwise operation & Simulation)

Source: Internet
Author: User

Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 3257


Hello world! Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 476 accepted submission (s): 180


Problem descriptionyour task is to print... er... "Hello world"... in a fantastic way -- using a beautiful font.

I 've sent you a nice font for you to use, but I'm too busy to tell you how. Can you help yourself?
Inputthe first line contains a single integer T (t <= 20), the number of test cases.
Each case begins with an integer c (1 <= C <= 80) in a single line, then each of the following C lines contains five two-digit numbers in hex (letters will be in uppercase ). don't ask me what they mean, I'm too busy...

Outputfor each test case, print the case number in the first line, then followed by a blank line.
After that, print all t characters. Use a single blank column of spaces between two consecutive characters. Each line shocould have exactly 6c-1 character (again, don't ask me why ).
Don't forget to print another blank line after the output of each test case.
Sample Input
 
2117f 08 08 08 7f38 54 54 1800 41 7f 40 0000 41 7f 40 0038 44 44 44 3800 00 00 00 00 003f 40 38 40 3f38 44 44 44 387c 08 04 04 0800 41 7f 40 0038 44 44 48 7f514 08 3E 08 1404 02 01 02 0440 40 40 40 4004 02 01 02 0414 08 3E 08 14

Sample output
Case 1: ######################################## ######################################## ######################################## ####### Case 2: #####################################

Source2009 Asia Regional Ningbo online

Ideas:
First, we thought of this question as a hexadecimal conversion to binary. We set the shader TT to 1, and then move it to the left using the bitwise operation (<),
Every time a is moved, all a [] and the current TT & (and) are performed once. If the value is 1, the binary of the current A [I] is described.
Here there is 1, that is, the "#" should be output (mainly using bit operations '<' and '&');
Try again!


The Code is as follows:

// # Pragma warning (Disable: 4786) # include <cstdio> # include <cmath> # include <cstring> # include <string> # include <cstdlib> # include <climits> # include <ctype. h> # include <queue> # include <stack> # include <vector> # include <utility> # include <deque> # include <set> # include <map> # include <iostream> # include <algorithm> using namespace STD; const double EPS = 1e-9; // const double Pi = atan (1.0) * 4; const double Pi = 3.1 415926535897932384626; # define INF 1e18 // typedef long ll; // typedef _ int64 ll; # define maxn 80*5 + 47int main () {int t; int N; int A [maxn]; int CAS = 0; scanf ("% d", & T); While (t --) {scanf ("% d", & N ); for (INT I = 0; I <5 * n; I ++) {scanf ("% x", & A [I]) ;} int tt; printf ("case % d: \ n", ++ CAS); For (INT I = 0; I <7; I ++) {TT = 1; TT <= I; for (Int J = 0; j <5 * n; j ++) {If (J! = 0 & J % 5 = 0) printf (""); if (a [J] & TT) printf ("#"); else printf ("");} printf ("\ n");} printf ("\ n");} return 0 ;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.