Codeforces - 337C(div2) - Harmony Analysis(找规律)

本文探讨了一门关于在4维空间内找到特定向量的数学问题,并提供了将问题推广到更高维度的解决方案。通过实例展示如何利用规律性解决这类问题。

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

嘿嘿嘿,找规律题,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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值