When the three groups can be introduced before observation recursive law, the next generation type, each with its own row opposite to copy itself.
Title Description
Gromah and LZR have entered the third level. There is a blank grid of size
m\times mm×m, and above the grid is a word "CDMA".
The inner product of two sequences
s,t_{}s,t with the same length n_{}n equals to \sum_{i=1}^{n} s_it_i∑i=1nsiti.
So, the key to the next level is to construct a grid of size
m\times mm×m, whose elements are all -1_{}−1 or 1_{}1, and for any two different rows, the inner product of them should be exactly 0_{}0.
Enter a description:
Only one positive integer
m_{}m in one line.
m \in \{2^k \; | \;k = 1, 2, \cdots, 10\}m∈{2k∣k=1,2,⋯,10}
Output Description:
Print m_{}m lines, each contains a sequence with length m_{}m, whose elements should be all -1_{}−1 or 1_{}1 satisfying that for any two different rows, the inner product of them equals 0_{}0.
You may print multiple blank spaces between two numbers or at the end of each line, and you may print any number of blank characters at the end of whole output file.
Example 1
Explanation
The inner product of the two rows is 1\times(-1) + 1\times 1 = 01×(−1)+1×1=0.
代码如下
1 #include <iostream> 2 #include <math.h> 3 using namespace std; 4 char a[1050][1050]; 5 int main(){ 6 int n,m,aa(1); 7 a[0][0]='1'; 8 a[0][1]='1'; 9 a[1][0]='1'; 10 a[1][1]='0'; 11 cin>>n; 12 if(n==2){ 13 cout<<"1 1\n"; 14 cout<<"1 -1\n"; 15 return 0; 16 } 17 m=log2(n)-1; 18 while(m--){ 19 aa=aa*2; 20 for(int k=0, t=aa;k<aa;k++,t++){ 21 for(int i=0,j=aa;j<2*aa;j++,i++){ 22 if(a[k][i]=='1') { 23 a[k][j]='0'; 24 a[t][i]='1'; 25 a[t][j]='1'; 26 } 27 else { 28 a[k][j]='1'; 29 a[t][i]='0'; 30 a[t][j]='0'; 31 } 32 } 33 } 34 } 35 for(int i=0;i<n;i++){ 36 for(int j=0;j<n;j++){ 37 if(a[i][j]=='1') cout<<"1 "; 38 else cout<<"-1 "; 39 } 40 cout<<'\n'; 41 } 42 }