Super Resolution

Super Resolution

Accepted : 121   Submit : 187
Time Limit : 1000 MS   Memory Limit : 65536 KB 

 

Super Resolution

Bobo has an n×picture consists of black and white pixels. He loves the picture so he would like to scale it a×times. That is, to replace each pixel with a× block of pixels with the same color (see the example for clarity).

Input

The input contains zero or more test cases and is terminated by end-of-file. For each test case,

The first line contains four integers n,m,a,. The i-th of the following n lines contains a binary string of length which denotes the i-th row of the original picture. Character "0" stands for a white pixel while the character "1" stands for black one.

  • 1n,m,a,b10
  • The number of tests cases does not exceed 10.

Output

For each case, output n×a rows and m×b columns which denote the result.

Sample Input

2 2 1 1
10
11
2 2 2 2
10
11
2 2 2 3
10
11

Sample Output

10
11
1100
1100
1111
1111
111000
111000
111111
111111

 

 

/简单模拟题,将一个 n*m 矩阵放大 a,b 倍

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <string.h>
 4 using namespace std;
 5 #define MX 205
 6 
 7 int num[MX][MX];
 8 int ans[MX][MX];
 9 
10 
11 int main()
12 {
13     int n,m,a,b;
14     while (scanf("%d%d%d%d",&n,&m,&a,&b)!=EOF)
15     {
16         for (int i=1;i<=n;i++)
17         {
18             char str[20];
19             scanf("%s",str);
20             for (int j=1;j<=m;j++)
21                 num[i][j]=str[j-1]-'0';
22         }
23         for (int i=1;i<=n;i++)
24             for (int j=1;j<=m;j++)
25                 for (int x=1;x<=a;x++)
26                     for (int y=1;y<=b;y++)
27                         ans[(i-1)*a+x][(j-1)*b+y]=num[i][j];
28         for (int i=1;i<=n*a;i++)
29         {
30             for (int j=1;j<=m*b;j++)
31                 printf("%d",ans[i][j]);
32             putchar(10);
33         }
34     }
35     return 0;
36 }
View Code

 

posted @ 2017-05-16 10:21  happy_codes  阅读(256)  评论(0编辑  收藏  举报