UVA 1605 Building for UN--联合国大厦
来源:互联网 发布:单片机仿真软件程序 编辑:程序博客网 时间:2024/05/11 01:28
题意:修建一个长方体的联合国大厦,n个国家入驻,要求任意两个国家最少存在一对办公室相邻(相邻:隔一层墙或者一层天花板) 输出楼层H, 每层楼有w 行,l 列。
思路:参照紫书上的思路是,一共有两层,每层都是n*n的,第一层的第i行全是国家i,第二层的第j列全是国家j的。
AC代码:
#include<cstdio>#include<cstring>using namespace std;const int maxn = 52;char a[maxn] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};int main(){int n;while(scanf("%d",&n)==1){printf("%d %d %d\n",2,n,n);for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){ printf("%c",a[i]); if(j == n-1)printf("\n"); } printf("\n"); for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){ printf("%c",a[j]); if(j == n-1)printf("\n"); } printf("\n");}return 0;}
阅读全文
0 0
- UVA 1605 Building for UN--联合国大厦
- UVA 1605 - Building for UN
- Uva - 1605 - Building for UN
- UVA 1605 Building for UN
- uva 1605 Building for UN
- UVA 1605 Building for UN
- UVA 1605Building for UN
- 联合国大楼UVA1605(Building for UN)
- uva uva 1605 - Building for UN
- Building for UN UVA
- Building for UN UVA
- Building for UN UVA
- UVA - 1605 Building for UN 水题
- uva 1605 ——Building for UN
- UVA 1605(p236)----Building for UN
- uva 1605 Building for UN 构造?随意
- UVa OJ 1605 - Building for UN
- UVA 1605 Building for UN 机智题。。
- Java中的事务——JDBC事务和JTA事务
- 排序与查找实例(四):归并排序
- 【POST 与 GET的真正区别】深入浅出
- lintcode python代码 420 报数
- countDownLatch、wait与notify
- UVA 1605 Building for UN--联合国大厦
- 【markdown】常用语法备忘
- SQL查询面试题
- SQL SERVER触发器应用案例讲解(deleted表或者inserted表) 转载
- Volley使用JsonObjectRequest发送Post请求失败
- kmp算法 java实现
- IO流
- Ubuntu下手动安装Firefox最新版本
- 记SharedPreferences封装类