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
嘿嘿嘿,找规律题,so happy
本来2^9维光想想就要命,根本不知道怎么玩= =虽然多种情况任意输出,但是感觉一种就够我炸了= =
然后自己画了画........0 0?.........0 0!2^1维和2^2维画了几种2333尼玛就是个找规律啊,摔!
规律:答案分成四部分,左上部分 = 右上部分= 左下部分,右下部分跟他们相反(应该也有其他规律,不过懒得看了= =)(我才不说我是靠2^1维2^2维强行猜的规律= =)
求2^(k-1)维扩展到2^k维,所以从2^1维扩展到2^9维,进行预处理
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <stdlib.h>
#include <cmath>
#include <cstring>
#include <string.h>
#include <cstdlib>
#include <iostream>
#include <set>
using namespace std;
int a[550][550];
int main()
{
int n;
memset(a, 0, sizeof(a));
a[0][0] = 1;
int cnt = 1;
int sum = 9;
while(sum--){
for(int i = 0; i < cnt; i++){
for(int j = 0; j < cnt; j++){
a[i + cnt][j] = a[i][j + cnt] = a[i][j];
a[i + cnt][j + cnt] = -a[i][j];
}
}
cnt *= 2;
}
while(scanf("%d", &n) != EOF){
int ans = 1;
for(int i = 0; i < n; i++)
ans *= 2;
for(int i = 0; i < ans; i++){
for(int j = 0; j < ans; j++){
if(a[i][j] == 1)
printf("+");
else
printf("*");
}
printf("\n");
}
}
return 0;
}
本文探讨了一门关于在4维空间内找到特定向量的数学问题,并提供了将问题推广到更高维度的解决方案。通过实例展示如何利用规律性解决这类问题。
&spm=1001.2101.3001.5002&articleId=50556325&d=1&t=3&u=6eabad95a5fd440f966eef5e54970dc2)
1072

被折叠的 条评论
为什么被折叠?



