题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
class Solution {
public:
int dx[4]={-1,-1,1,1},dy[4]={1,-1,-1,1};
int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {
int res=2;
if(a==e)
{
if(c!=a) res=1;
if(b<d&&d<f||d>f&&d<b) ;
else res=1;
}
if(b==f){
if(b!=d) res=1;
if(a<c&&c<e||a>c&&c>e) ;
else res=1;
}
//大象
for(int i=0;i<4;i++){
int tx=c,ty=d;
bool ok=false;
while(1){
tx+=dx[i],ty+=dy[i];
if(tx<=0||ty<=0||tx>8||ty>8||tx==a&&ty==b) break;
if(tx==e&&ty==f){
ok=true;
break;
}
}
if(ok) res=1;
}
return res;
}
};
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
大佬,题解和打卡没多大区别呀。
啊这不是打卡吗,打卡不都是这么写的吗0.0
题解,要写一写思路吧。
好的思密达,佬周末都还在卷