找到 n*n 2D 矩阵的元素的最小总和,这样我必须从每一行和每列中选择一个且仅一个元素?例如
4 12
6 6
Run Code Online (Sandbox Code Playgroud)
如果我4从 row 中选择,1我不能12从 row1 也从 column 中1选择,我只能从第 2 行第 2 列中选择 6。
所以,同样的最低金额是4 + 6 = 10其中6从第二行第二列
而不是6 + 12 = 18其中6是从第二行第一列
也4 + 12不允许,因为两者都来自同一行
我想到了蛮力,一旦我从行和列中选择元素,我就无法选择另一个,但这种方法是O(n!)
.
在C++中,std :: string类实现了比较运算符.下面的代码打印AAA
#include <iostream>
using namespace std;
int main() {
if("9">"111")
cout << "AAA";
else
cout << "not AAA";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这个片段打印not AAA:
#include <iostream>
using namespace std;
int main() {
if("9">"111")
cout << "AAA";
else
cout << "not AAA";
if("99">"990")
cout << "BBB";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么会这样?