#include<stdio.h>
#include<string.h>
#include<math.h>
void K(int a[],int n)
{
int num;
for (int i = 0; i <= n - 1; i++)
{
for (int r = i + 1; r <= n - 1; r++)
{
if (a[i] > a[r])
{
num = a[i];
a[i] = a[r];
a[r] = num;
}
}
}
}
int main()
{
int n, a[10000], m, b, c;
scanf("%d", &m);
for (int r = 1; r <= m; r++)
{
memset(a, 0, sizeof(a));
b = 1;
c = 1;
scanf("%d", &n);
for (int i = 0; i <= n - 1; i++)
scanf("%d", &a[i]);
K(a, n);/*排序后相同项会彼此相连*/
for (int e = 0; e <= n - 2; e++)
{
while (a[e] == a[e + 1])
{
b++;
e++;
}
if (b >= c)
{
c = b;/*计算最长相同项长度并记录*/
}
b = 1;
}
printf("%d\n", c);
}
return 0;
}
相关文章
- 03-18最长上升子序列-二、问题简析
- 03-18LeetCode-1143. 最长公共子序列【字符串 动态规划】-解题思路一:动规五部曲
- 03-1877. 最长公共子序列
- 03-18[TJOI2013]最长上升子序列 平衡树
- 03-18[LeetCode] 128. 最长连续序列
- 03-18Q673 最长递增子序列的个数
- 03-18POJ 3903 Stock Exchange 【最长上升子序列】模板题
- 03-181281:最长上升子序列
- 03-18最长公共子上升序列(LCIS)
- 03-18HDU-1423-Greatest Common Increasing Subsequence-最长公共上升子序列【模版】