简单的很,十分钟不到就切掉了,做这道黄题是因为今天写累了不想写代码了,就最后做一道简单的。看来黄题对我而言基本就是“一半能切一半想一会之后能切”,除非题目是思维题
1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <cstdio> 5 #include <algorithm> 6 #include <cmath> 7 #define int long long 8 char *p1,*p2,buf[100000]; 9 #define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++) 10 using namespace std; 11 int read() 12 { 13 int x=0,f=1; 14 char ch=nc(); 15 while(ch<48||ch>57) 16 { 17 if(ch=='-') 18 f=-1; 19 ch=nc(); 20 } 21 while(ch>=48&&ch<=57) 22 x=x*10+ch-48,ch=nc(); 23 return x*f; 24 } 25 int m[1050][1050]; 26 void div(int x1,int y1,int x2,int y2) 27 { 28 if(x1==x2)return; 29 int dx=(x1+x2)/2,dy=(y1+y2)/2; 30 for(int i=x1;i<=dx;i++) 31 { 32 for(int j=y1;j<=dy;j++) 33 { 34 m[i][j]=1; 35 } 36 } 37 div(x1,dy+1,dx,y2); 38 div(dx+1,y1,x2,dy); 39 div(dx+1,dy+1,x2,y2); 40 } 41 signed main() 42 { 43 int n; 44 cin>>n; 45 div(1,1,1<<n,1<<n); 46 for(int i=1;i<=(1<<n);i++) 47 { 48 for(int j=1;j<=(1<<n);j++) 49 { 50 if(m[i][j]==1)cout<<"0 "; 51 else cout<<"1 "; 52 } 53 cout<<endl; 54 } 55 56 return 0; 57 }View Code
TRANSLATE with x English TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back 标签:p2,P5461,ch,递归,nc,p1,&&,include From: https://www.cnblogs.com/gongkai/p/18039849