题目 样例
6
4
20 22 19 84
4
1 11 1 2022
4
1100 1100 1100 1111
5
12 34 56 78 90
4
1 9 8 4
6
16 38 94 25 18 99
YES
YES
NO
NO
YES
YES
代码:
#include<bits/stdc++.h>
using namespace std;
int a[10005],tong[15];
int t,n,m=10;
int panduan()
{
for(int I=0;I<=9;I++)
for(int J=0;J<=9;J++)
for(int K=0;K<=9;K++)
{
if((I+J+K)%m==3&&tong[I]>0&&tong[J]>0&&tong[K]>0)
{
return 1;
break;
}
}
return 0;
}
int main()
{
cin>>t;
for(int i=1;i<=t;i++)
{
memset(tong, 0, sizeof tong);
cin>>n;
for(int j=1;j<=n;j++)
{
cin>>a[i];
tong[a[i]%m]++;
}
if(panduan())
cout<<"YES"<<endl;else
cout<<"NO"<<endl;
}
}