• UVa1605


    UVA - 1605

    Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu

    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<tex2html_verbatim_mark> 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<tex2html_verbatim_mark>(1$ le$n$ le$50)<tex2html_verbatim_mark> -- 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<tex2html_verbatim_mark> , w<tex2html_verbatim_mark> , and l<tex2html_verbatim_mark> -- height, width and length of the building respectively.

    h<tex2html_verbatim_mark> descriptions of floors should follow. Each floor description consists of l<tex2html_verbatim_mark> lines with w<tex2html_verbatim_mark> 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<tex2html_verbatim_mark> 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

    题解:
    要求设计一个包含若干层的联合国大楼,其中每层都是一个等大的网格,若干国家需要在里面办公,你需要把每个格子分配给一个国家,使得任意格子的国家都有一个相邻的格子(同层中公共边的格子,上下相邻层的同一个格子),输入国家的个数,要求输出每一层的平面图.不要被题意迷惑。。。只需要设计两层就可以了,每个国家占第一层的每一行,占第二层的每一列,这样的话就既满足联通又相邻了。


    #include <stdio.h>
    #include <string.h>
    int main()
    {
        int n;
        while(scanf("%d",&n))
        {
            printf("2 %d %d
    ",n,n);
            for(int i=0; i< n; i++) ///第一层
            {
                for(int j=0; j<n; j++)
                {
                    if(i<26)
                        printf("%c",'A'+i);
                    else
                        printf("%c",'a'+i-26);
                }
                printf("
    ");
            }
            printf("
    ");
            for(int i=0; i<n; i++) ///第二层
            {
                for(int j=0; j<n; j++)
                {
                    if(j<26)
                        printf("%c",'A'+j);
                    else
                        printf("%c",'a'+j-26);
                }
                printf("
    ");
            }
        }
        return 0;
    }
     
  • 相关阅读:
    SlidingMenu官方实例分析8——CustomAnimation
    SlidingMenu官方实例分析7——SlidingContent和SlidingTitleBar区别
    SlidingMenu官方实例分析5——FragmentChangeActivity
    SlidingMenu官方实例分析4——AttachExample
    云虚拟主机和云服务器的区别
    SAP MM常用表
    dedecms 模板文件不存在,无法解析文档"的终极各种解决办法
    js代码如何测试代码运行时间
    java 连接msql数据库
    Java 创建xml文件和操作xml数据
  • 原文地址:https://www.cnblogs.com/hfc-xx/p/4702331.html
Copyright © 2020-2023  润新知