cf(打磨你)(大模拟)
来源:互联网 发布:玛雅注册机mac 编辑:程序博客网 时间:2024/04/29 10:12
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square 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 and yi determine the length and width of the logo of the i-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 square n, where you can place all the three logos. Each of the next n 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
模拟打印出来三个矩形拼成的正方形,仔细思考一下子也不是没有可能,不过可能就是麻烦了一些。。。。可能有更简洁的办法。
三个矩形拼成正方形无非也只有样例里边给出来的两种大情况,所以我们需要自己的耐心然后努力思考做题就ok啦~~!
#include <iostream>#include <stdio.h>#include <stdlib.h>#include<string.h>#include<algorithm>#include<math.h>#define mod 1000000007using namespace std;typedef long long ll;int main(){ int x[3],y[3]; cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]; int s=x[0]*y[0]+x[1]*y[1]+x[2]*y[2],t=sqrt((double)s); if(t*t!=s) cout<<-1<<endl; else { int b=0; if(x[0]==t||y[0]==t)b++; if(x[1]==t||y[1]==t)b++; if(x[2]==t||y[2]==t)b++; if(b==3) { cout<<t<<endl; int bl[3]; for(int i=0;i<3;i++) if(x[i]!=t) bl[i]=x[i]; else bl[i]=y[i]; for(int j=0;j<bl[0];j++) {for(int i=0;i<t;i++) cout<<'A';cout<<endl; } for(int j=0;j<bl[1];j++) {for(int i=0;i<t;i++) cout<<'B';cout<<endl; } for(int j=0;j<bl[2];j++) {for(int i=0;i<t;i++) cout<<'C';cout<<endl; } }else if(b==1) { int bj; for(int i=0;i<3;i++) if(x[i]==t||y[i]==t) bj=i; if(bj==0) { int flag=1,l1,w1; if(x[0]!=t)l1=x[0]; else l1=y[0]; if(x[1]==x[2]&&y[1]+y[2]==t&&x[1]+l1==t) { w1=y[1]; }else if(x[1]==y[2]&&y[1]+x[2]==t&&x[1]+l1==t) { w1=y[1]; }else if(y[1]==y[2]&&x[1]+x[2]==t&&y[1]+l1==t) { w1=x[1]; }else if(y[1]==x[2]&&x[1]+y[2]==t&&y[1]+l1==t) { w1=x[1]; }else flag=0; if(!flag) cout<<-1<<endl; else { cout<<t<<endl; for(int i=0;i<t;i++) if(i<l1) { for(int j=0;j<t;j++) cout<<'A'; cout<<endl; }else { for(int j=0;j<w1;j++) cout<<'B'; for(int j=w1;j<t;j++) cout<<'C'; cout<<endl; } } }else if(bj==1) { int flag=1,l1,w1; if(x[1]!=t)l1=x[1]; else l1=y[1]; if(x[0]==x[2]&&y[0]+y[2]==t&&x[0]+l1==t) { w1=y[0]; }else if(x[0]==y[2]&&y[0]+x[2]==t&&x[0]+l1==t) { w1=y[0]; }else if(y[0]==y[2]&&x[0]+x[2]==t&&y[0]+l1==t) { w1=x[0]; }else if(y[0]==x[2]&&x[0]+y[2]==t&&y[0]+l1==t) { w1=x[0]; }else flag=0; if(!flag) cout<<-1<<endl; else { cout<<t<<endl; for(int i=0;i<t;i++) if(i<l1) { for(int j=0;j<t;j++) cout<<'B'; cout<<endl; }else { for(int j=0;j<w1;j++) cout<<'A'; for(int j=w1;j<t;j++) cout<<'C'; cout<<endl; } } }else { int flag=1,l1,w1; if(x[2]!=t)l1=x[2]; else l1=y[2]; if(x[1]==x[0]&&y[1]+y[0]==t&&x[1]+l1==t) { w1=y[1]; }else if(x[1]==y[0]&&y[1]+x[0]==t&&x[1]+l1==t) { w1=y[1]; }else if(y[1]==y[0]&&x[1]+x[0]==t&&y[1]+l1==t) { w1=x[1]; }else if(y[1]==x[0]&&x[1]+y[0]==t&&y[1]+l1==t) { w1=x[1]; }else flag=0; if(!flag) cout<<-1<<endl; else { cout<<t<<endl; for(int i=0;i<t;i++) if(i<l1) { for(int j=0;j<t;j++) cout<<'C'; cout<<endl; }else { for(int j=0;j<w1;j++) cout<<'B'; for(int j=w1;j<t;j++) cout<<'A'; cout<<endl; } } } } else cout<<-1<<endl; } return 0;}
- cf(打磨你)(大模拟)
- cf(模拟)
- cf(找规律,模拟)
- cf#402 E 大模拟
- CF D. Population Size(贪心+模拟)
- cf 46-d (模拟区间覆盖)
- 某场CF B Octagons(模拟)
- CF 883H Palindromic Cut(模拟)
- 如何打磨一个受欢迎的山寨app(1)
- 如何打磨一个受欢迎的山寨app(2)
- CF Bayan 2015 Contest Warm Up A.(模拟+预处理)
- C. New Year Book Reading(CF)模拟
- CF 205 C Little Elephant and Interval(模拟)
- cf C. The Big Race (简单模拟)
- CF #347 (Div.2) C. International Olympiad(模拟)
- CF #364 (Div. 2)( A. Cards 简单模拟)
- cf - 140 A. New Year Table(模拟)
- 模拟(Epidemic in Monstropolis,cf 733C)
- LitePal中需要用到的Model
- NVLink技术及影响解析
- AndroidManifest.xml中Activity的定义
- 网络爬虫介绍及数据采集
- Android快速SDK(7)图像加载库ImageLoader【傻瓜模式】
- cf(打磨你)(大模拟)
- 软件架构师成长之路
- 一些异常封装
- AndroidStudio快速入门二:Gradle快速构建Android项目(多个Module同时构建)
- 在LitePal中解析XML
- LitePal的CRUD操作
- framework调用第三方的Jar包
- leetcode:Best Time to Buy and Sell Stock I II II
- 几个 Java main方法面试题