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:
![](https://i-blog.csdnimg.cn/blog_migrate/fa0f66e31dca09737d28ceb5fae47f9d.png)
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行,每行一个向量2^k个字符,+表示+1,*表示-1,使向量之间两两
- 两两正交,
- ac代码·
-
#include<stdio.h> #include<stdlib.h> #include<iostream> #include<algorithm> using namespace std; char map[(1<<9)+100][(1<<9)+100]; void dfs(int n,int x,int y,int val) { if(n==1) { if(val==1) map[x][y]='+'; else map[x][y]='*'; return; } dfs(n>>1,x,y,val); dfs(n>>1,x+n/2,y,val); dfs(n>>1,x,y+n/2,val); dfs(n>>1,x+n/2,y+n/2,-val); } int main() { int n; while(scanf("%d",&n)!=EOF) { dfs(1<<n,1,1,1); int i,j; for(i=1;i<=(1<<n);i++) { for(j=1;j<=(1<<n);j++) printf("%c",map[i][j]); printf("\n"); } } }