Codeforces 610C 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.

Sample test(s)
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维的互相叉乘都是0的向量。'+'表示1, '*'表示0。



无限YY。。。就这么过了。

每个方案分左上、右上、左下、右下4部分。左上、下相同,右上一半与同左上,另一半相反,右上右下相反。


AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <string>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define MAXN (2000+10)
#define MAXM (500000)
#define Ri(a) scanf("%d", &a)
#define Rl(a) scanf("%lld", &a)
#define Rf(a) scanf("%lf", &a)
#define Rs(a) scanf("%s", a)
#define Pi(a) printf("%d\n", (a))
#define Pf(a) printf("%.2lf\n", (a))
#define Pl(a) printf("%lld\n", (a))
#define Ps(a) printf("%s\n", (a))
#define W(a) while(a--)
#define CLR(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define LL long long
#define lson o<<1, l, mid
#define rson o<<1|1, mid+1, r
#define ll o<<1
#define rr o<<1|1
#define PI acos(-1.0)
using namespace std;
char Map[MAXN][MAXN];
void getMap(int n)
{
    Map[0][0] = '+';
    for(int k = 1; k <= n; k++)
    {
        int len = 1<<(k-1);
        int lcul = 1<<(k-1), rcul = 1<<k;
        int lrow = 0, rrow = 1<<(k-1);
        for(int i = lrow; i <= rrow/2; i++)
            for(int j = lcul; j < rcul; j++)
                Map[i][j] = Map[i][j-len] == '+' ? '*' : '+';
        for(int i = rrow/2; i < rrow; i++)
            for(int j = lcul; j < rcul; j++)
                Map[i][j] = Map[i][j-len];
        lcul = 0; rcul = 1<<(k-1);
        lrow = 1<<(k-1); rrow = 1<<k;
        for(int i = lrow; i < rrow; i++)
            for(int j = lcul; j < rcul; j++)
                Map[i][j] = Map[i-len][j];
        lcul = 1<<(k-1); rcul = 1<<k;
        lrow = 1<<(k-1); rrow = 1<<k;
        for(int i = lrow; i < rrow; i++)
            for(int j = lcul; j < rcul; j++)
                Map[i][j] = Map[i-len][j] == '+' ? '*' : '+';
    }
}
int main()
{
    int k; Ri(k);
    getMap(k);
    for(int i = 0; i < (1<<k); i++)
        Ps(Map[i]);
    return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值