Codeforces #337 (Div.2)C.Harmony Analysis【构造】

C. Harmony Analysis
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every coordinate of every vector is 1 or  - 1 and any two vectors are orthogonal. Just as a reminder, two vectors in n-dimensional space are considered to be orthogonal if and only if their scalar product is equal to zero, that is:

.

Danil quickly managed to come up with the solution for this problem and the teacher noticed that the problem can be solved in a more general case for 2k vectors in 2k-dimensinoal space. When Danil came home, he quickly came up with the solution for this problem. Can you cope with it?

Input

The only line of the input contains a single integer k (0 ≤ k ≤ 9).

Output

Print 2k lines consisting of 2k characters each. The j-th character of the i-th line must be equal to ' * ' if the j-th coordinate of the i-th vector is equal to  - 1, and must be equal to ' + ' if it's equal to  + 1. It's guaranteed that the answer always exists.

If there are many correct answers, print any.

Examples
Input
2
Output
++**
+*+*
++++
+**+
Note

Consider all scalar products in example:

  • Vectors 1 and 2: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( + 1) + ( - 1)·( - 1) = 0
  • Vectors 1 and 3: ( + 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) + ( - 1)·( + 1) = 0
  • Vectors 1 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( - 1) + ( - 1)·( + 1) = 0
  • Vectors 2 and 3: ( + 1)·( + 1) + ( - 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) = 0
  • Vectors 2 and 4: ( + 1)·( + 1) + ( - 1)·( - 1) + ( + 1)·( - 1) + ( - 1)·( + 1) = 0
  • Vectors 3 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( + 1)·( - 1) + ( + 1)·( + 1) = 0

题目大意:

让你构造出一个2^k*2^k的一个矩阵(只包含1和-1),令每行构成一个向量,保证使得每一个向量的叉乘都是0,输出格式:+表示1,*表示-1.


思路:


1、当n==2的时候

ans:

++

+*

2、当n==3的时候,将4*4的格子分成四部分,分别是左上左下右上和右下四个部分。然后将n==2时候的矩阵当做左上部分,然后平移过去形成右上,平移下去形成左下。右下的部分是左上部分取反得到。然后n==4的时候同理,依次类推即可。


Ac代码:


#include<stdio.h>
#include<string.h>
using namespace std;
int a[1000][1000];
int main()
{
    a[1][1]=1;
    a[1][2]=1;
    a[2][1]=1;
    a[2][2]=0;
    for(int z=2;z<=9;z++)
    {
        int m=(1<<(z-1));
        for(int i=1;i<=m;i++)
        {
            for(int j=1;j<=m;j++)
            {
                a[i+m][j]=a[i][j];
                a[i][j+m]=a[i][j];
                a[i+m][j+m]=1-a[i][j];
            }
        }
    }
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=(1<<n);i++)
        {
            for(int j=1;j<=(1<<n);j++)
            {
                if(a[i][j]==1)
                {
                    printf("+");
                }
                else printf("*");
            }
            printf("\n");
        }
    }
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值