Lay a solid foundation - P1319 compression technology

Topic links: https://www.luogu.org/problem/P1319

P1319 compression technology

Title Description

A set of N × N by the characters 0 and 1 of the lattice pattern composition.

We generate compression code in accordance with the following rules. A continuous set of values: calculated from the first line of the first symbol character dot-matrix pattern, by writing order from left to right, top to bottom. Several consecutive first number indicates 0, the second number represents the next successive Several 1, then the next successive third number there are several 0, then the number of the fourth number of consecutive 1, so ......

For example: The following Character dot pattern:

0001000
0001000
0001111
0001000
0001000
0001000
1111111

Corresponding compression code is: 731,616,431,616,137 (the first number is N, and the remaining bits represent the number indicates alternately 0 and 1, to ensure that the compressed code of alternating N × N = and the number of Members)

Input Format

Line, compressed code.

Output Format

Bitmap characters (no spaces between the dot symbol). (3 <= N <= 200)

Sample input and output

Input # 1
7 3 1 6 1 6 4 3 1 6 1 6 1 3 7
Output # 1
0001000 
0001000 
0001111 
0001000 
0001000 
0001000 
1111111 

This question is very water of a question, in fact, nothing really difficult, and I do not speak directly on the code!
 1 #include <iostream>
 2 #include <cstdio>
 3 
 4 using namespace std;
 5 
 6 int n,a[10100],s=1;
 7 
 8 int main()
 9 {
10     cin>>n;
11     while(scanf("%d",&a[s])!=EOF) s++;
12     int k=1,t=1;
13     for(int i=1;i<=s;i++)
14     {
15         k=(k+1)%2;
16         for(int j=a[i];j>0;j--)
17         {
18             if(t>n)
19             {
20                 t=1;
21                 cout<<endl;
22             }
23             cout<<k,t++;
24         }
25     }
26     return 0;
27 }

Lay a solid foundation, do a good job each question! ! !

Author: Gmax

This article belongs to the author and blog Park total, reproduced, please use the link, please do not reprint the original, Thanks ♪ (· ω ·) Techno

2019-08-10

Guess you like

Origin www.cnblogs.com/Gmax/p/11330681.html