hdu6313( 2018 Multi-University Training Contest 2)

bryce1010模板

http://acm.hdu.edu.cn/showproblem.php?pid=6313

参考dls的讲解:
以5*5的矩阵为例:
后一列分别对前一列+0+1+2+3+4操作:
+0:10000 10000 10000 10000 10000
+1:10000 01000 00100 00010 00001
+2:10000 00100 00001 01000 00010
+3:10000 00010 10000 00100 00001
+4:10000 00001 01000 00010 10000

然后sqrt(2000)接近47
所以设n=47;
找到一个规律公式:
gg[i*n+j][k*n+(j*k+i)%n]=1;
0<=i<47;0<=j<47;0<=k<47;

#include<bits/stdc++.h>
using namespace std;
const int n=47;
const int MAXN=3333;
int gg[MAXN][MAXN];


int main()
{
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            for(int k=0;k<n;k++)
                gg[i*n+j][k*n+(j*k+i)%n]=1;
    cout<<2000<<endl;
    for(int i=0;i<2000;i++)
    {
        for(int j=0;j<2000;j++)
        {
            cout<<gg[i][j];
        }
        cout<<endl;
    }
    return 0;


}
posted @ 2018-07-27 18:26  Bryce1010  阅读(105)  评论(0编辑  收藏  举报