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;


}

相关文章:

  • 2021-09-20
  • 2021-08-30
  • 2021-06-12
  • 2022-02-13
  • 2021-09-06
  • 2022-02-26
  • 2021-11-13
  • 2018-07-24
猜你喜欢
  • 2021-08-02
  • 2021-05-31
  • 2021-08-23
  • 2021-06-13
相关资源
相似解决方案