UVA 1605 Building for UN--YHX

Source: Internet
Author: User
Tags integer numbers

The Nations has decided to build a new headquarters in Saint Petersburg, Russia. It would have a
form of a rectangular parallelepiped and would consist of several rectangular
Oors, one on top of another.
each
Oor is a rectangular grid of the same dimensions, each cell of this grid is an office.
Offices is considered adjacent if they is located on the same
Oor and share a common wall,
Or if one ' s
Oor is the other ' s ceiling.
The St. Petersburg building would host N national missions. Each country gets several offices that
form a connected set.
Moreover, modern political situation shows, countries might want to form secret coalitions. For
That to is possible, each pair of countries must has 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 is hired to design a appropriate building for the UN.
Input
Input consists of several datasets. Each of them have a single integer number n (1 N 50) | The
Number of countries that is hosted in the building.
Output
On the RST 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
Oors should follow. each
Oor description consists of L lines with W characters on
Each line. Separate descriptions of adjacent
Oors with a empty line.
Use capital and small Latin letters to denote offices of different countries. There should is at the most
1 offices in the building. Each office should is 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.

1#include <cstdio>2#include <cstring>3 CharTurnintx)4 {5     if(x<= -)returnx+'a'-1;6     returnX- -+'A';7 }8 intMain ()9 {Ten     inti,j,k,m,n,p,q,x,y,z,l,h; One     CharC; A     BOOLb=0; -      while(SCANF ("%d", &n) = =1) -     { the         if(b==0) b=1; -         Elseprintf"\ n"); -printf"2%d%d\n", n,n); -          for(i=1; i<=n;i++) +         { -              for(j=1; j<=n;j++) +printf"%c", turn (i)); Aprintf"\ n"); at         } -printf"\ n"); -          for(i=1; i<=n;i++) -         { -              for(j=1; j<=n;j++) -printf"%c", Turn (j)); inprintf"\ n"); -         } to     } +}

As with http://www.cnblogs.com/AwesomeOrion/p/5380752.html, it just lets you find a set of solutions. Then I just want to construct the universal solution.

My method is: Build two layers, each layer n*n, the first layer is arranged in order 1. N, the second layer is vertically arranged in order of 1. N, so that every two countries will cross.

UVA 1605 Building for UN--YHX

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.