例题8-2:联合国大楼
来源:互联网 发布:淘宝秒杀助手mac 编辑:程序博客网 时间:2024/05/01 01:21
例题8-2:联合国大楼
题目大意:
有n个国家,要求你设计一栋楼并为这n个国家划分房间,要求国家的房间必须连通,且每两个国家之间必须有一间房间是相邻的
解题思路:
只需要设计两层就可以了,每个国家占第一层的每一行,占第二层的每一列,这样的话就既满足联通又相邻了
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<string>#include<cmath>#include<set>#include<queue>#include<map>#include<stack>#include<vector>#include<list>#include<deque>using namespace std;typedef long long ll;const int maxn = 1e6 + 10;const double eps = 1e-6;const int INF = 1 << 30;int T, n, m;char Map[100];void init(){ for(int i = 0; i < 26; i++)Map[i] = i + 'a'; for(int i = 26; i < 52; i++)Map[i] = i - 26 + 'A';}int main(){ init(); while(cin >> n) { cout<<"2 "<<n<<" "<<n<<endl; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { printf("%c",Map[i]); } printf("\n"); } cout<<endl; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { printf("%c",Map[j]); } printf("\n"); } } return 0;}
阅读全文
0 0
- 例题8-2:联合国大楼
- 例题8-2 联合国大楼 UVa 1605
- UVa1605 例题8-2 联合国大楼(Building for UN,ACM/ICPC NEERC 2007)
- 例题8-2 联合国大楼(Building for UN, ACM/ICPC NEERC 2007, UVa1605)
- 联合国大楼
- 联合国大楼UVa1605
- 联合国大楼UVA1605(Building for UN)
- 水题(联合国大楼,uva 1605)
- 2009-2-9 央视大楼着火喽
- 例题2
- 语言联合国
- 装饰大楼
- C语言例题8:
- 例题3-8
- 例题4-8
- 例题8-1 UVA
- 例题8-1:煎饼
- 例题2-2
- XTU 1273 set
- RHEL7CentOS7 精简操作指令
- ctguoj--考新郎(排列组合+错排公式)
- 例题8-1:煎饼
- 由冒泡排序想到的
- 例题8-2:联合国大楼
- mysql导入表时出现的问题,1153
- mysql中的 skip-name-resolve 问题
- XTU 1272 Robot
- Hibernate5用户手册中文版 PDF 下载
- arrayAdapter.notifyDataSetChanged()
- spring源码与架构分析——Spring框架的一些理解
- 字符流(缓冲区问题)
- BIG-IP系统iRules基本概念_v11.6.1