Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 548    Accepted Submission(s): 170
Special Judge
let count be a 2d array filled with 0s
iterate through all 1s in the matrix:
suppose this 1 lies in grid(x,y)
iterate every row r:
if grid(r,y)=1:
++count[min(r,x)][max(r,x)]
if count[min(r,x)][max(r,x)]>1:
claim there is a rectangle satisfying the condition
claim there isn‘t any rectangle satisfying the condition
10000 10000 10000 10000 10000 
10000 01000 00100 00010 00001 
10000 00100 00001 01000 00010 
10000 00010 01000 00001 00100 
10000 00001 00010 00100 01000 
11000  11000 11000  11000 11000 
01000 00100 00010 00001 10000 
01000 00010 10000 00100 00001 
01000 00001 00100 10000 00010 
01000 10000 00001 00010 00100 
01100 01100  01100  01100  01100 
其实就是某种意义上的+1,+2,。。。
 
#include <iostream> #include <string> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <map> #define range(i,a,b) for(auto i=a;i<=b;++i) #define LL long long #define itrange(i,a,b) for(auto i=a;i!=b;++i) #define rerange(i,a,b) for(auto i=a;i>=b;--i) #define fill(arr,tmp) memset(arr,tmp,sizeof(arr)) using namespace std; int grid[3005][3005],p=47; void init(){ range(i,0,p)range(j,0,p)range(k,0,p)grid[i*p+j][(j*k+i)%p+k*p]=1; } void solve(){ puts("2000"); range(i,0,1999) { range(j,0,1999){ putchar(grid[i][j]+48); if(!((j+1)%5))putchar(‘ ‘); } putchar(‘\n‘); } } int main() { init(); solve(); return 0; }
面向题解编程后,勉强理解了公式。。。这里直接放标程了。。
 
#include <stdio.h> int P=47,f[233333],an=0,gg[2333][2333]; int main() { for(int i=0;i<P;i++) { for(int r=0;r<P;++r) { ++an; for(int j=i,k=0;k<P;k++,j=(j+r)%P) f[j*P+k]=an; for(int j=0;j<P*P;++j) if(f[j]==an) gg[i*P+r][j]=1; } } printf("%d\n",1999); for(int i=0;i<1999;++i,puts("")) for(int j=0;j<1999;++j) putchar(gg[i+2][j+2]+48); }
原文:https://www.cnblogs.com/Rhythm-/p/9371123.html