Codeforces 610C

610C - Harmony Analysis

思路:

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define pi acos(-1.0) 
#define pii pair<int,int>
#define pil pair<int,ll>
#define mem(a,b) memset(a,b,sizeof(a))

const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
const int N=1e5+5;
//head

int dp[550][550];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    dp[0][0]=1;
    int t=9;
    int c=1;
    while(t--)
    {
        for(int i=0;i<c;i++)
        {
            for(int j=0;j<c;j++)
            {
                dp[i][j+c]=dp[i][j];
                dp[i+c][j]=dp[i][j];
                dp[i+c][j+c]=-dp[i][j];
            }
        }
        c<<=1;
    } 
    
    int k;
    cin>>k;
    int n=pow(2,k);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(dp[i][j]==1)cout<<'+';
            else cout<<'*';
        }
        cout<<endl;
    }
    return 0;
} 
原文地址:https://www.cnblogs.com/widsom/p/7403066.html