2 * 2 matrix structure opposite foot off the cattle 2019 summer school and more training camp (Session 8)

Title: https: //ac.nowcoder.com/acm/contest/888/C

#include<bits/stdc++.h>
using namespace std;
const int M=2e3+3;
int n,A[M][M];
void dfs(int x){
    if(x==1){
        A[1][1]=1;
        return ;
    }
    int t=x/2;
    dfs(t);
    for (int i=1;i<=t;i++)
        for (int j=1;j<=t;j++){
            A[i+t][j]=A[i][j+t]= A[i][j];
            A[i+t][j+t]=-A[i][j];
        }
}

int main()
{
    cin>>n;
    dfs(n);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            printf("%d%c",A[i][j],j==n?'\n':' ');
    return 0;
}
View Code

 

 

Guess you like

Origin www.cnblogs.com/starve/p/12004768.html