@TOC
做题总结
很久没有刷题了,回洛谷刷题发现做题过程中一些问题。
主要是以下几个点:
1.做题中对很表层的现象进行规律总结,导致得出了错误的函数映射关系,导致代码逻辑思维出错
2.对相同性的东西没有很好的总结好,其实就是要注意题目中的特殊性
以上两点导致我做题过程非常缓慢,拖慢了整个进度
另外就是本题中的一些具体的点:
1.本题中的x,y映射没有处理好,其实只要处理好坐标映射的方法,再顺着题意递归就好了
#include<bits/stdc++.h>
using namespace std;
const int MAXX=1055;
int n;
int matrix[MAXX][MAXX];
struct state{
int x;
int y;
state(int a,int b):x(a),y(b){};
};
bool IsEqual(state startPos,state endPos)
{
return startPos.x==endPos.x&&startPos.y==endPos.y;
}
void Try(state startPos,state endPos)
{
if(IsEqual(startPos,endPos)){
matrix[startPos.x][startPos.y]=1;
return;
}
state nextStartPos_1(startPos.x,(endPos.y-startPos.y)/2+1+startPos.y),
nextStartPos_2((endPos.x-startPos.x)/2+1+startPos.x,startPos.y),
nextStartPos_3((endPos.x-startPos.x)/2+1+startPos.x,(endPos.y-startPos.y)/2+1+startPos.y);
state nextEndPos_1((endPos.x-startPos.x)/2+startPos.x,endPos.y),
nextEndPos_2(endPos.x,(endPos.y-startPos.y)/2+startPos.y),
nextEndPos_3(endPos.x,endPos.y);
Try(nextStartPos_1,nextEndPos_1);
Try(nextStartPos_2,nextEndPos_2);
Try(nextStartPos_3,nextEndPos_3);
}
void show(int n)
{
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cout<<matrix[i][j]<<' ';
}
cout<<endl;
}
}
int main()
{
int x;
cin>>n;
n=pow(2,n);
std::ios::sync_with_stdio(false);
state startPos(1,1),endPos(n,n);
Try(startPos,endPos);
show(n);
return 0;
}