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-11 15:08
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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