zoukankan      html  css  js  c++  java
  • UVA1605-Building for UN(思维)

    Problem UVA1605-Building for UN

    Accept: 398  Submit: 2303
    Time Limit: 10000 mSec

    Problem Description

    The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a form of a rectangular parallelepiped and will consist of several rectangular floors, one on top of another. Each floor is a rectangular grid of the same dimensions, each cell of this grid is an office. Two offices are considered adjacent if they are located on the same floor and share a common wall, or if one’s floor is the other’s ceiling. The St. Petersburg building will host n national missions. Each country gets several offices that form a connected set. Moreover, modern political situation shows that countries might want to form secret coalitions. For that to be possible, each pair of countries must have at least one pair of adjacent offices, so that they can raise the wall or the ceiling they share to perform secret pair-wise negotiations just in case they need to. You are hired to design an appropriate building for the UN.

    Input

    Input consists of several datasets. Each of them has a single integer number n (1 ≤ n ≤ 50) — the number of countries that are hosted in the building.

     Output

    On the first line of the output for each dataset write three integer numbers h, w, and l — height, width and length of the building respectively. h descriptions of floors should follow. Each floor description consists of l lines with w characters on each line. Separate descriptions of adjacent floors with an empty line. Use capital and small Latin letters to denote offices of different countries. There should be at most 1 000 000 offices in the building. Each office should be occupied by a country. There should be exactly n different countries in the building. In this problem the required building design always exists. Print a blank line between test cases.

     

     Sample Input

    4
     

     Sample Output

    2 2 2

    AB

    CC


    zz zz

    题解:水题,啥限制都没有,不要求最小,字典序之类的,随便画一画就出来了。

     1 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 
     5 const int maxn = 60;
     6 
     7 char gra[maxn][maxn], gra2[maxn][maxn];
     8 
     9 int main()
    10 {
    11     int n;
    12     while (~scanf("%d", &n)) {
    13         printf("%d %d %d
    ", 2, n, n);
    14         for (int i = 0; i < n; i++) {
    15             for (int j = 0; j < n; j++) {
    16                 if(i < 26) gra[i][j] = 'A' + i;
    17                 else gra[i][j] = 'a' + i - 26;
    18             }
    19         }
    20 
    21         for (int j = 0; j < n; j++) {
    22             for (int i = 0; i < n; i++) {
    23                 if(j < 26) gra2[i][j] = 'A' + j;
    24                 else gra2[i][j] = 'a' + j - 26;
    25             }
    26         }
    27 
    28         for (int i = 0; i < n; i++) {
    29             for (int j = 0; j < n; j++) {
    30                 printf("%c", gra[i][j]);
    31             }
    32             printf("
    ");
    33         }
    34         printf("
    ");
    35         for (int i = 0; i < n; i++) {
    36             for (int j = 0; j < n; j++) {
    37                 printf("%c", gra2[i][j]);
    38             }
    39             printf("
    ");
    40         }
    41         printf("
    ");
    42     }
    43     return 0;
    44 }
  • 相关阅读:
    更快的datetime string to python datetime转换模块 ciso8601
    华为新员工入职培训计划曝光!你留不住员工的原因就在这! zz
    在vmware中安装macos系统 vm12 osx10.11 or higher
    vmware for linux (centos65) 卸载相关
    第八章多态
    第七章 复用类
    第六章 访问权限控制
    Think in Java 第四 五 章
    Think in Java 第三章操作符
    Thank in Java
  • 原文地址:https://www.cnblogs.com/npugen/p/9610962.html
Copyright © 2011-2022 走看看