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
++** +*+* ++++ +**+
把2^k-1复制3分,最后一份乘上-1就是2^k的答案
#include <bits/stdc++.h>
#define maxn 50005
#define MOD 1000000007
using namespace std;
typedef long long ll;
int m[605][605], k;
void solve(int p, int t, int r, int h){
for(int i = 1; i <= h; i++)
for(int j = 1; j <= h; j++){
m[i+p-1][j+t-1] = m[i][j] * r;
}
}
void dfs(int d){
if(d == 2){
m[1][1] = 1, m[1][2] = 1;
m[2][1] = -1, m[2][2] = 1;
return ;
}
dfs(d / 2);
solve(1, d/2+1, 1, d/2);
solve(d/2+1, 1, 1, d/2);
solve(d/2+1, d/2+1, -1, d/2);
}
int main(){
// freopen("in.txt", "r", stdin);
scanf("%d", &k);
int d = 1 << k;
if(k == 0){
puts("+");
return 0;
}
dfs(d);
for(int i = 1; i <= d; i++){
for(int j = 1; j <= d; j++){
if(m[i][j] == 1)
putchar('+');
else
putchar('*');
}
puts("");
}
return 0;
}