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 ...
随机推荐
- Python_简单三级菜单制作
一:制作要求 1.三级菜单 2.可依次选择进入各子菜单 3.所需新知识点:字典,列表 *本文通过三种方法完成,第一种:只使用循环,第二种:使用列表,第三种:使用字典 二:FlowChart流程图 与上 ...
- Spring Boot(Spring的自动整合框架)
Spring Boot 是一套基于Spring框架的微服务框架,由于Spring是一个轻量级的企业开发框架,主要功能就是用于整合和管理其他框架,想法是将平时主流使用到的框架的整合配置预先写好,然后通过 ...
- epoll代码示例
#include <errno.h> #include <string.h> #include <stdlib.h> #include <sys/types. ...
- cookie 和 session区别
cookie 和 session区别 ① cookie介绍说明 cookie 存放在浏览器缓存中---浏览器进行查看(谷歌) [设置]---[高级]---[内容设置]---[cookie]---[所有 ...
- Filter防止用户访问一些未被授权的资源
package com.drp.util.filter; import java.io.IOException; import javax.servlet.Filter; import javax.s ...
- 一个简单的scrollTop动画的方法
var autoScrollTop = function (param) { var delay = param.scrollDom.height() * 20; param.dom.animate( ...
- 腾讯.NET&PHP面试题
在整个面试过程中,作为面试者的你,角色就是小怪兽,面试官的角色则是奥特曼,更不幸的是,作为小怪兽的你是孤身一人,而奥特曼却往往有好几个助攻,你总是被虐得不要不要的~ 作为复读一年才考上专科的我,遗憾的 ...
- ie6常见的兼容性问题
1.<!DOCTYPE HTML>文档类型的声明. 产生条件:IE6浏览器,当我们没有书写这个文档声明的时候,会触发IE6浏览器的怪异解析现象: 解决办法:书写文档声明. 2.不同浏览器当 ...
- (后端)springboot 在idea中实现热部署(转)
自己用到了iIntelliJ IDEA 这个ide工具,但是和以前的工具写html,css,js直接刷新页面不同,这个需要去热部署,网上搜的解决方法: SpringBoot的web项目,在每一次修改了 ...
- SQL SERVER数据库级的触发器
CREATE TRIGGER [Object_Change_Trigger_DDL] ON database FOR DROP_TABLE AS DECLARE @EventData AS xml; ...