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
Sample Output
2 2 2
AB
CC
zz zz
题解:水题,啥限制都没有,不要求最小,字典序之类的,随便画一画就出来了。
#include <bits/stdc++.h> using namespace std; const int maxn = ; char gra[maxn][maxn], gra2[maxn][maxn]; int main()
{
int n;
while (~scanf("%d", &n)) {
printf("%d %d %d\n", , n, n);
for (int i = ; i < n; i++) {
for (int j = ; j < n; j++) {
if(i < ) gra[i][j] = 'A' + i;
else gra[i][j] = 'a' + i - ;
}
} for (int j = ; j < n; j++) {
for (int i = ; i < n; i++) {
if(j < ) gra2[i][j] = 'A' + j;
else gra2[i][j] = 'a' + j - ;
}
} for (int i = ; i < n; i++) {
for (int j = ; j < n; j++) {
printf("%c", gra[i][j]);
}
printf("\n");
}
printf("\n");
for (int i = ; i < n; i++) {
for (int j = ; j < n; j++) {
printf("%c", gra2[i][j]);
}
printf("\n");
}
printf("\n");
}
return ;
}
UVA1605-Building for UN(思维)的更多相关文章
- UVa1605 - Building for UN(构造法)
UVA - 1605 Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Description ...
- UVA 1605 Building for UN(思维)
题目链接: https://cn.vjudge.net/problem/UVA-1605#author=0 /* 问题 设计一个包含若干层的联合国大厦,其中每一层都是等大的网格,每个格子分配给一个国家 ...
- UVa1605,Building for UN
我比较好奇的是uva后台是怎么测这题的 没什么可说的,那些不想敲但还是想直接交这题的直接copy过去吧 #include <iostream> #include <cstring&g ...
- UVA-1605 Building for UN (构造)
题目大意:n个国家的人要在一栋大厦里办公,要求任意两个国家的办公室要相邻(同层同边或邻层同面),设计一个满足要求的方案. 题目分析:题目限制较少,任意构造出一个解即可. 代码如下: # include ...
- uva1605 - Building for UN(构造法)
这道题构造出的结果很妙,考察思维能力.就两层,每层都n*n个格子,第一层第i行都放国家i,第二层第j列都放国家j. 需要注意的是ASCII中A至Z在a至z的前面(数字小),而且它们两组不挨着.所以需要 ...
- HDU 5538 House Building(模拟——思维)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5538 Problem Description Have you ever played the vi ...
- 8-2 Building for UN Uva1605
题意:你的任务是设计一个包含若干层的联合国大楼,其中每层都是一个等大的网络 由若干个国家需要在联合国大楼里面办公 你需要把每个格子分配给一个国家 使得任意两个不同的国家都有一对相邻的格子 (要没是同 ...
- 【例题 8-2 UVA-1605】Building for UN
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 两层 然后n*n就够了 第一层类似 aaa.. bbb.. ccc.. ... 第二次则变成 abc.... abc.... abc ...
- 架构师修炼 II - 表达思维与驾驭方法论
开篇之前我想先说说当年开发的那点事儿:大约10年前吧,我还是一个程序员的时候经常都是遇到这样的项目开发流程: 解决方案 :满足客户目的和投标用的一堆文档(不少还是互联网上抄的) ,是以Word为主的纯 ...
- 5 Tips for Building a Winning DevOps Culture
对于企业来说,前途未卜的改变往往很难发生,就像航海一样,重复的往往是久经验证的安全航线,这点在DevOps文化的构建上同样如此.近日,CA Technologies的高级策略师Peter Waterh ...
随机推荐
- 【Java每日一题】20170322
20170321问题解析请点击今日问题下方的“[Java每日一题]20170322”查看(问题解析在公众号首发,公众号ID:weknow619) package Mar2017; public cla ...
- Java类加载机制(加载、验证、准备、解析、初始化)
如下图所示,Java的类加载机制主要分为三个部分,分别为加载.链接.初始化.其中链接又分为三个小部分--验证.准备.解析. 加载--在经过对Java代码进行编译后,JVM将Java类编译后的二进制文件 ...
- 如何通过setTimeout理解JS运行机制详解
setTimeout()函数:用来指定某个函数或某段代码在多少毫秒之后执行.它返回一个整数,表示定时器timer的编号,可以用来取消该定时器. 例子 ? 1 2 3 4 5 console.log(1 ...
- Locust 安装
环境:CentOS 7.4,python2.7.5 # 安装 pip yum -y install python-pip # 安装 locustio pip install locustio mkdi ...
- C#基础(201)--常量枚举
本文知识点: 1.掌握常量的定义和使用方法 2.理解枚举的作用和特点 3.掌握枚举的使用方法 1.1.常量的定义语法 const 数据类型 常量名称 = 值: 1.2.常见错误 1.3常量的 ...
- Ios12怎么投屏到电脑 苹果手机投屏电脑的方法
苹果手机是一款外观精致时尚的手机,吸引这许多用户争先恐后的购买,然后苹果手机的系统不同于我们传统使用的安卓系统,它采用的是苹果自主研发的IOS系统,有许多操作与安卓手机不同,那么苹果手机怎么用呢?下面 ...
- CSS的基本语法
W3School离线手册(2017.03.11版)下载:https://pan.baidu.com/s/1c6cUPE7jC45mmwMfM6598A CSS(层叠样式表) ...
- js获取选中日期的当周的周一和周日
js获取选中日期的当周的周一和周日 第一种方法(推荐): function getWeekStr(str) { // 将字符串转为标准时间格式 str2 = Date.parse(str); let ...
- SQL强化练习(面试与学习必备)
一.经典选课题A 1.1.请同时使用GUI手动与SQL指令的形式创建数据库.表并添加数据. 题目:设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教 ...
- SQL Server中sp_spaceused统计数据使用的空间总量不正确的原因
很多时候,我们经常使用sp_spaceused来查看表的空间使用情况,上个月群里有个网友说他使用DELETE删除了数据后,使用sp_spaceused查看,发现该表的分配的空间总量(reserved) ...