题意: 构造一个n*n 的 01 矩阵, 0 < n < 2001, 矩阵需要满足没有一个子矩阵的4个角都是1,并且矩阵内1的个数至少有85000个。
题解:数论构造题
代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",stdout); 4 #define LL long long 5 #define ULL unsigned LL 6 #define fi first 7 #define se second 8 #define pb push_back 9 #define lson l,m,rt<<1 10 #define rson m+1,r,rt<<1|1 11 #define max3(a,b,c) max(a,max(b,c)) 12 #define min3(a,b,c) min(a,min(b,c)) 13 typedef pair<int,int> pll; 14 const int inf = 0x3f3f3f3f; 15 const LL INF = 0x3f3f3f3f3f3f3f3f; 16 const LL mod = (int)1e9+7; 17 int P = 47; 18 const int N = 3010; 19 int a[N][N]; 20 int main(){ 21 int n, m; 22 for(int i = 0; i < P; i++) 23 for(int j = 0; j < P; j++) 24 for(int k = 0; k < P; k++) 25 a[i*P + j][k*P + (k*i+j)%P] = 1; 26 puts("2000"); 27 for(int i = 0; i < 2000; i++){ 28 for(int j = 0; j < 2000; j++) 29 printf("%d", a[i][j]); 30 puts(""); 31 } 32 return 0; 33 }