• 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;
    }
  • 相关阅读:
    小学四则运算APP 最后阶段
    小学四则运算APP 第三阶段冲刺-第一天
    小学四则运算APP 第二阶段冲刺-第五天
    小学四则运算APP 第二次冲刺 第四天
    小学四则运算APP 第二阶段冲刺-第三天
    小学四则运算APP 第二次冲刺-第二天
    小学四则运算APP 第二个冲刺 第一天
    小学四则运算APP 第一个冲刺 第八天
    小学四则运算APP 第一个冲刺 第七天
    小学四则运算APP 第一个冲刺阶段 第六天
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5081928.html
Copyright © 2020-2023  润新知