P5461【黄】-递归
简单的很,十分钟不到就切掉了,做这道黄题是因为今天写累了不想写代码了,就最后做一道简单的。看来黄题对我而言基本就是“一半能切一半想一会之后能切”,除非题目是思维题

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 }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」