UVA - 1605 Building for UN (联合国大楼)
Posted SomnusMistletoe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA - 1605 Building for UN (联合国大楼)相关的知识,希望对你有一定的参考价值。
题意:一个联合国大楼每层都有数量相等大小相同的格子,将其分配给n个国家,使任意两个不同的国家都相邻(同层有公共边或相邻层的同一个格子)。
分析:可以设计一个只有两层的大楼,第一层每个国家占一行,第二层每个国家占一列,即每层都是n*n的。
#pragma comment(linker, "/STACK:102400000, 102400000") #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<cmath> #include<iostream> #include<sstream> #include<iterator> #include<algorithm> #include<string> #include<vector> #include<set> #include<map> #include<stack> #include<deque> #include<queue> #include<list> #define Min(a, b) ((a < b) ? a : b) #define Max(a, b) ((a < b) ? b : a) typedef long long ll; typedef unsigned long long llu; const int INT_INF = 0x3f3f3f3f; const int INT_M_INF = 0x7f7f7f7f; const ll LL_INF = 0x3f3f3f3f3f3f3f3f; const ll LL_M_INF = 0x7f7f7f7f7f7f7f7f; const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1}; const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1}; const int MOD = 1e9 + 7; const double pi = acos(-1.0); const double eps = 1e-8; const int MAXN = 10000 + 10; const int MAXT = 10000 + 10; using namespace std; map<int, char> mp; void init(){ string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; for(int i = 0; i < 52; ++i){ mp[i] = s[i]; } } int main(){ int n; init(); bool flag = true; while(scanf("%d", &n) == 1){ if(flag) flag = false; else printf("\n"); printf("2 %d %d\n", n, n); for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ printf("%c", mp[i]); } printf("\n"); } printf("\n"); for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ printf("%c", mp[j]); } printf("\n"); } } return 0; }
以上是关于UVA - 1605 Building for UN (联合国大楼)的主要内容,如果未能解决你的问题,请参考以下文章
例题 8-2 UVA-1605Building for UN
UVA - 1605 Building for UN (联合国大楼)