BNUOJ 3685 Building for UN 联合国 【贪心】

题目链接:

  http://acm.bnu.edu.cn/v3/problem_show.php?pid=3685


贪心:

  有n个国家,要求你设计一栋楼并为这n个国家划分房间,要求相同国家的房间必须连通,且每两个国家之间必须有一间房间是相邻的
  只需要设计两层就可以了,每个国家占第一层的每一行,占第二层的每一列,这样的话就既满足联通又相邻了


 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cstdio>
 4 #include<cstring>
 5 using namespace std;
 6 char country[52];
 7 void Pre(){
 8     for(int i = 0; i < 26; i++) country[i] = 'A'+i;
 9     for(int i = 26; i < 52; i++) country[i] = 'a'+i-26;
10 }
11 
12 int main(){
13     Pre();
14     int n;
15     while(~scanf("%d", &n)){
16         printf("2 %d %d\n", n, n);
17         for(int i = 0; i < n; i++){
18             for(int j = 0; j < n; j++){
19                 printf("%c", country[i]);
20             }
21             printf("\n");
22         }
23         printf("\n");
24         for(int i = 0; i < n; i++){
25             for(int j = 0; j < n; j++){
26                 printf("%c", country[j]);
27             }
28             printf("\n");
29         }
30     }
31 
32     return 0;
33 }

 

转载于:https://www.cnblogs.com/miaowTracy/p/4858713.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值