2*2右脚相反矩阵构造 2019牛客暑期多校训练营(第八场)

题: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

 

 

posted @ 2019-12-08 10:32  starve_to_death  阅读(146)  评论(0编辑  收藏  举报