• Codeforces Round #337 (Div. 2) C. Harmony Analysis 构造


    C. Harmony Analysis

    题目连接:

    http://www.codeforces.com/contest/610/problem/C

    Description

    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 Input

    2

    Sample Output

    ++**

    ++

    ++++

    +**+

    Hint

    题意

    要求你构造出2^n个2^n维向量,使得向量之间两两相乘都等于0

    题解:

    瞎构造的。。。

    大概证明可以由数学归纳法证明

    假设我现在已经构造出了

    a

    那么我就可以构造出

    a a

    a -a

    然后一直重复就好了。。。

    代码

    #include<bits/stdc++.h>
    using namespace std;
    
    int dp[1200][1200];
    int n;
    int main()
    {
        scanf("%d",&n);
        dp[0][0]=1;
        for(int x=1;x<=n;x++)
        {
            for(int i=0;i<(1<<x-1);i++)
            {
                for(int j=0;j<(1<<x-1);j++)
                {
                    dp[i][j+(1<<x-1)]=dp[i][j];
                    dp[i+(1<<x-1)][j]=dp[i][j];
                    dp[i+(1<<x-1)][j+(1<<x-1)]=1-dp[i][j];
                }
            }
        }
        for(int i=0;i<(1<<n);i++)
        {
            for(int j=0;j<(1<<n);j++)
            {
                if(dp[i][j])printf("+");
                else printf("*");
            }
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    vue 按需加载
    需要打印真实尺寸大小等需求的,css的单位可以使用mm等做单位
    d3 比例尺
    d3 根据数据绘制svg
    d3 svg简单学习
    d3 使用随机数据生成条形图
    d3 画简单的柱形图
    d3 使用数据
    d3 数据绑定
    d3 添加元素相关api
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5081928.html
Copyright © 2020-2023  润新知