首页 > 代码库 > 137 - ZOJ Monthly, November 2014 - J Poker Face

137 - ZOJ Monthly, November 2014 - J Poker Face

Poker Face

Time Limit: 2 Seconds      Memory Limit: 65536 KB

As is known to all, coders are lack of exercise and Kato is one of them. In order to get fit, he decides to go mining in MINECRAFT. However, it is always dangerous in the mine because there are a lot of ZOMBIEs in MINECRAFT. They kill Kato time and time again when he is mining. But this time, Kato is in invincible mode and wants to observe what the ZOMBIEs‘ faces are like. After his obervation, he found that the ZOMBIEs‘ faces are regular. Now he provides you the ZOMBIEs‘ faces of size 8, 16 and 32, it is your task to draw the other ZOMBIEs. You should find the recursivepattern from the small cases and learn to draw bigger cases.

Input

There are multiple test cases. For each case there is only a number N (8 ≤ N≤ 1024, N is a power of 2), which is size of the ZOMBIE‘s face. The input ends with an integer less than eight.

Output

For each case, output the image of the ZOMBIE‘s face. And print an empty line after each case.

Sample Input

816320

Sample Output

***********  ******  ******  **** **** ** *  * ** *  * **************************              ** ****    **** ** *  *    *  * ** *  *    *  * ** *  *    *  * ** ****    **** **              **   ********   **   * *  * *   **   * *  * *   **   * **** *   **   ***  ***   **   ***  ***   **   ***  ***   **************************************************                              **                              **                              **   ********        ********   **   *      *        *      *   **   *      *        *      *   **   *      *        *      *   **   *      *        *      *   **   *      *        *      *   **   *      *        *      *   **   *      *        *      *   **   ********        ********   **                              **                              **                              **       ****************       **       *   ***  ***   *       **       *   ***  ***   *       **       *   ***  ***   *       **       *   * **** *   *       **       *   * *  * *   *       **       *   * *  * *   *       **       *   ********   *       **       *              *       **       * ****    **** *       **       * *  *    *  * *       **       * *  *    *  * *       **       * *  *    *  * *       **       * ****    **** *       **       *              *       *********************************

Hint

The sample out put is the ZOMBIE‘s face of size 8, 16, 32.

Author: ZHU, Heming

 

解题:递推打印就是了。。。

#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <climits>#include <vector>#include <queue>#include <cstdlib>#include <string>#include <set>#include <stack>#define LL long long#define INF 0x3f3f3f3f#define pii pair<int,int>using namespace std;const int maxn = 2000;int n;char table[11][maxn][maxn];void printLine(int m,int n,int x,int y) {    for(int i = 0; i < n; ++i)        table[m][x][y+i] = *;}void printR(int m,int n,int x,int y) {    for(int i = 0; i < n-1; ++i) {        table[m][x+i][y] = *;        for(int j = 1; j < n-1; ++j)            table[m][x+i][y+j] =  ;        table[m][x+i][y+n-1] = *;    }}void printG(int m,int n) {    for(int i = 0; i < n; ++i) {        for(int j = 0; j < n; ++j)            putchar(table[m][i][j]);        putchar(\n);    }}void printB(int n,int x,int y,int m) {    for(int i = n-1; i >= 0; --i) {        for(int j = 0; j < n; ++j) {            table[m][x+i][y+j] = table[m-1][i][j];        }    }}void draw(int m,int n) {    printLine(m,n,0,0);    printR(m,n,1,0);    printLine(m,n,n-1,0);    printLine(m,n>>2,n>>3,n>>3);    printR(m,n>>2,(n>>3)+1,n>>3);    printLine(m,n>>2,(n>>3)+(n>>2),n>>3);    printLine(m,n>>2,n>>3,n-(n>>3)-(n>>2));    printR(m,n>>2,(n>>3)+1,n-(n>>3)-(n>>2));    printLine(m,n>>2,(n>>3)+(n>>2),n-(n>>3)-(n>>2));}void draw2(int m,int n) {    int y = n>>2;    int x = (n>>1);    for(int i = (n>>1)-1; i >= 0; --i,x++) {        for(int j = 0; j < (n>>1); ++j)            table[m][x][y+j] = table[m-1][i][j];    }}int main() {    memset(table, ,sizeof(table));    draw(3,1<<3);    printLine(3,4,4,2);    table[3][5][2] = table[3][5][5] = *;    table[3][6][2] = table[3][6][5] = *;    for(int i = 4; i <= 10; ++i) {        draw(i,1<<i);        draw2(i,1<<i);    }    while(scanf("%d",&n),n >= 8) {        int k = log2(n)+0.5;        printG(k,n);        putchar(\n);    }    return 0;}
View Code

 

137 - ZOJ Monthly, November 2014 - J Poker Face