感觉思路没错,为什么不对?
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
const int M=1e3+5;
const ll MOD=1e4+7;
int T;
int a[N];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>T;
while(T--)
{
int n,x,ans;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(a[1]!=a[i])
ans=1;
}
if(ans==1)
cout<<n-1<<endl;
else cout<<n<<endl;
}
return 0;
}