cf(打磨你)(大模拟)

D. Three Logos
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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.

Output

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.

Sample test(s)
input
5 1 2 5 5 2
output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
input
4 4 2 6 4 2
output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC


模拟打印出来三个矩形拼成的正方形,仔细思考一下子也不是没有可能,不过可能就是麻烦了一些。。。。可能有更简洁的办法。

三个矩形拼成正方形无非也只有样例里边给出来的两种大情况,所以我们需要自己的耐心然后努力思考做题就ok啦~~!


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#define mod 1000000007
using 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;
}

转载于:https://www.cnblogs.com/martinue/p/5490486.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的公寓报修管理系统,源码+数据库+毕业论文+视频演示 现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本公寓报修管理系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此公寓报修管理系统利用当下成熟完善的Spring Boot框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的MySQL数据库进行程序开发。公寓报修管理系统有管理员,住户,维修人员。管理员可以管理住户信息和维修人员信息,可以审核维修人员的请假信息,住户可以申请维修,可以对维修结果评价,维修人员负责住户提交的维修信息,也可以请假。公寓报修管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。 关键词:公寓报修管理系统;Spring Boot框架;MySQL;自动化;VUE
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值