2019湖南多校第5场网络同步赛B

Little Barney just got a new toy cube set from his parents. His set contains n identical cubes. Barney immediately started building various objects with these cubes.

The latest thing Barney built is a stair. A stair consists of one or more towers of cubes, where the heights of towers are non-increasing from left to right. In the following picture, you can see three different shapes with 12 cubes each. The first two are stairs and the third one is not a stair.

Barney noticed that for some stairs you can turn your head 90 degrees to the right and you will see the same stair, but reversed! He calls such stairs symmetric. For example, the first stair above is symmetric, but the second one is not. Formally, a stair is symmetric if and only if when you reflect the picture over the x = y line, you get the same stair (where the x-axis is horizontal and oriented to the right, and the y-axis is vertical and oriented upwards).

Barney wants to build a symmetric stair using all of his n cubes. Show him how to do it!

Input

The single line of the input contains an integer n --- the number of cubes at Barney's disposal (1 ≤ n ≤ 100).

Output

If there is no symmetric stair with n cubes, output a single integer −1.

Otherwise, in the first line, output one integer m --- the number of rows and columns in the picture of the stair (1 ≤ m ≤ 100). Then, output m lines describing the stair. Each line must contain exactly m characters 'o' (a lowercase English letter) or '.', where 'o' describes a cell with a cube, and '.' describes an empty cell. There must be exactly n 'o' characters in total. The cell in the bottom left corner must contain a cube. If there is more than one solution, output any of them.

Sample Input

3

Sample Output

3
...
o..
oo.

Hint

这题只有n=2不行

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==1)
        {
            printf("1\no\n");
            continue;
        }
        if(n==2)
        {
            printf("-1");
            continue;
        }
        if(n%2==1)
        {

            int m;
            m=(n-1)/2+1;
            printf("%d\n",m);
            for(int i=1; i<=m-1; i++)
            {
                printf("o");
                for(int j=2; j<=m; j++)
                {
                    printf(".");
                }
                printf("\n");
            }
            for(int i=1; i<=m; i++)
            {
                printf("o");
            }
            printf("\n");
        }
        else
        {

            int m;
            m=(n-4)/2+2;
            printf("%d\n",m);
            for(int i=1; i<=m-2; i++)
            {
                printf("o");
                for(int j=2; j<=m; j++)
                {
                    printf(".");
                }
                printf("\n");
            }
            printf("oo");
            for(int i=3;i<=m;i++) printf(".");
            printf("\n");
            for(int i=1; i<=m; i++)
            {
                printf("o");
            }
            printf("\n");
        }
        /*int m,k;
        m=(n-i*i)/(2*i);
        k=(n-i*i)%(2*i);
        k/=2;
        printf("%d\n",i+m+1);
        //i+m+1 列
        for(int q=1;q<=k;q++) printf("o");//第一行
        for(int q=k+1;q<=i+m+1;q++) printf(".");
        printf("\n");
        for(int q=2;q<=m+1;q++)//
        {
            for(int p=1;p<=i;p++) printf("o");
            for(int p=i+1;p<=i+m+1;p++) printf(".");
            printf("\n");
        }
        for(int q=m+2;q<=i+m+1-k;q++)//
        {
            for(int p=1;p<=i+m;p++) printf("o");
            printf(".\n");
        }
        for(int q=i+m+1-k+1;q<=i+m+1;q++)//
        {
            for(int p=1;p<=i+m+1;p++) printf("o");
            printf("\n");
        }*/
    }
}



/**********************************************************************
	Problem: 2309
	User: 201805550815
	Language: C++
	Result: AC
	Time:4 ms
	Memory:1120 kb
**********************************************************************/

 

全部评论

相关推荐

07-16 14:10
门头沟学院 Java
点赞 评论 收藏
分享
写不来代码的小黑:这么小的城市能有做it的公司也不容易
点赞 评论 收藏
分享
06-15 02:05
已编辑
南昌航空大学 数据分析师
Eason三木:你如果想干技术岗,那几个发公众号合唱比赛的经历就去掉,优秀团员去掉,求职没用。然后CET4这种不是奖项,是技能,放到下面的专业技能里或者单独列一个英语能力。 另外好好改改你的排版,首行缩进完全没有必要,行间距好好调调,别让字和标题背景黏在一起,你下面说能做高质量PPT你得展现出来啊,你这简历排版我用PPT做的都能比你做的好。 然后自我评价,你如果要干数据工程师,抗压能力强最起码得有吧。
简历中的项目经历要怎么写
点赞 评论 收藏
分享
昨天 18:05
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务