Codeforces Round #322 D.Three Logos
来源:互联网 发布:如何找淘宝小二 编辑:程序博客网 时间:2024/05/22 10:49
Three companies decided to order a billboard with pictures of their logos. A billboard is a bigsquare board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi andyi determine the length and width of the logo of thei-th company respectively.
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of squaren, where you can place all the three logos. Each of the nextn lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
- the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
- the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
- the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
5 1 2 5 5 2
5AAAAABBBBBBBBBBCCCCCCCCCC
4 4 2 6 4 2
6BBBBBBBBBBBBAAAACCAAAACCAAAACCAAAACC本题题目意思也较为清楚,就是叫你给你三个长方形的长和宽,叫你判断他们能否组成一个正方形,并输出形状#include<bits/stdc++.h>using namespace std;int main(){ int x1,y1,x2,y2,x3,y3; while(scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF){ int area=x1*y1+x2*y2+x3*y3; int k=sqrt(area); if(k*k==area){ if(y1==k) swap(x1,y1); if(y2==k) swap(x2,y2); if(y3==k) swap(x3,y3); if(x1==k&&x2==k&&x3==k){ printf("%d\n",k); for(int i=1;i<=y1;i++){ for(int j=1;j<=x1;j++) printf("A"); printf("\n"); } for(int i=1;i<=y2;i++){ for(int j=1;j<=x2;j++) printf("B"); printf("\n"); } for(int i=1;i<=y3;i++){ for(int j=1;j<=x3;j++) printf("C"); printf("\n"); } continue; } int sd=0; if(x2==k){ sd=1; swap(x1,x2); swap(y1,y2); } if(x3==k){ sd=2; swap(x1,x3); swap(y1,y3); } if(y2==k-y1){ swap(x2,y2); } if(y3==k-y1){ swap(x3,y3); } if(x2==k-y1&&x3==k-y1&&y2+y3==k){ printf("%d\n",k); for(int i=1;i<=y1;i++){ for(int j=1;j<=x1;j++) printf("%c",'A'+sd); printf("\n"); } if(sd==0){ for(int i=1;i<=x2;i++){ for(int j=1;j<=y2;j++) printf("%c",'B'); for(int j=1;j<=y3;j++) printf("%c",'C'); printf("\n"); } } if(sd==1){ for(int i=1;i<=x2;i++){ for(int j=1;j<=y2;j++) printf("%c",'A'); for(int j=1;j<=y3;j++) printf("%c",'C'); printf("\n"); } } if(sd==2){ for(int i=1;i<=x2;i++){ for(int j=1;j<=y2;j++) printf("%c",'B'); for(int j=1;j<=y3;j++) printf("%c",'A'); printf("\n"); } } continue; } else{ printf("-1\n"); } } else{ printf("-1\n"); } } return 0;}
- Codeforces Round #322 D.Three Logos
- Codeforces Round #322 D Three Logos
- Codeforces Round #322 (Div. 2) D. Three Logos
- Codeforces Round #322 (Div. 2) D. Three Logos(暴力)
- Codeforces 581D Three Logos
- codeforces 581D Three Logos
- Codeforces 581D - Three Logos (枚举)
- Codeforces 581D Three Logos 模拟 枚举
- #322 (div.2) D. Three Logos
- Three Logos CodeForces
- D. Three Logos (CF Round #322 (Div.2) 瞎搞 分情况)
- 解题报告 之 CodeForces 581D Three Logos
- CF#322-D. Three Logos-模拟水题
- CF_#322(Div.2) D. Three Logos(greedy)
- Code Forces 581 D. Three Logos(计算几何)
- Three Logos(模拟)
- codeforces 120D Three Sons
- Codeforces Round#213D
- [转载]Cocos2d-x 类COC手游与RTS(即时战略)游戏的编程实践总结
- 类的初始化顺序:实例化一个类的对象和访问静态域或者静态方法时的不同
- 一些HTML5的替换写法
- javadoc中{@link}与@see的区别
- Visual Studio2010 出现“此时无足够的可用内存,无法满足操作的预期要求”问题的解决方法
- Codeforces Round #322 D.Three Logos
- php cli命令行模式运行mysql_connect不能连接和运行框架程序
- linux exec函数家族
- monkey测试2-测试策略
- vs2010的opencv2.4.11的配置
- hdu 5492 Find a path DP
- 【HNOI2006】【BZOJ1192】鬼谷子的钱袋
- monkey测试3-测试结果分析
- 视觉机器学习20讲 K-means