这是一道不错的入门题,虽然我很懒,写了 6 个 For 循环
我绝对不会告诉你们我是故意的,但是感觉可以这么做,懒得用前缀和。
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
for(int x = i; x <= n; x++){
for(int y = j; y <= m; y++){
int cnt = 0;
if(i == x){
for(int q = j; q <= y; q++){
if(carrot[i][q] == 1)
count++;
}
}
else if(j == h){
for(int q = i; q <= x; q++){
if(carrot[q][j]==1)
count++;
}
}
else{
for(int q = i; q <= f; q++){
for(int p = j; p <= h; p++){
if(carrot[q][p]==1)
count++;
}
}
}
if(count > =k){
int c = (x - i + 1) * (y - j + 1);
sum = min(sum, c);
}
}
}
}
}
我真的很无聊,虽然我现在一点也不忙
猜猜是那一题