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?
The only line of the input contains a single integer k (0 ≤ k ≤ 9).
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.
2
++** +*+* ++++ +**+
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
题意:给 k,构造2^k * 2^k的图, 使得任意两行 相乘相加值为0
题解:对于一个 满足了条件的 正方形,想要得到将其边长翻倍的图形 我们将它复制接右边,接到正下方,再取反接到斜对角,就是了;
根据这个我们从1*1得到 2*2得到 4*4---到答案
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int dp[1025][1025];
void dfs(int k)
{
if(k>=1024)
return ;
for(int i=0;i<k/2;i++)
{
for(int j=0;j<k/2;j++)
{
dp[i+k/2][j+k/2]=-dp[i][j];
dp[i+k/2]=dp[i][j];
dp[i][j+k/2]=dp[i][j];
}
}
dfs(k*2);
}
long long powd(long long a,long long b)
{
long long ans=1;
while(b>0)
{
if(b%2==1)
ans=ans*a;
b/=2;
a*=a;
}
return ans;
}
int main()
{
int n;
while(~scanf("%d",&n))
{
dp[0][0]=1;dp[0][1]=1;
dp[1][0]=1;dp[1][1]=-1;
dfs(4);
n=powd(2,n);
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(dp[i][j]==1)
printf("+");
else
printf("*");
}
printf("\n");
}
}
}