2021-08-23 AcWing 3814. 矩阵变换
输入样例1:
4
0101
1000
1111
0101
输出样例1:
2
输入样例2:
3
111
111
111
输出样例2:
3
结果res至少为 1,我们只需要找到最多的同类数就OK了
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
string s[110];
int main()
{
int t;
cin >> t;
int res=1;
for (int i = 0; i < t; i ++ )cin>>s[i];
for (int i = 0; i < t; i ++ )
{
int cnt=1;
for (int j = i+1; j < t; j ++ )
{
if(s[i]==s[j]){
cnt++;
}
}
res = max(res,cnt);
}
cout << res;
return 0;
}
本文来自博客园,作者:泥烟,CSDN同名, 转载请注明原文链接:https://www.cnblogs.com/Knight02/p/15799125.html