根据题目描述写,对于每组给定的数据判断是否满足四个要求就可以了。
#include <bits/stdc++.h>
using namespace std;
int x[120];
int main()
{
//freopen("in.txt","r",stdin);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--)
{
int n,flag = 1,yi = 0;
cin >> n;
for(int i = 0;i < n; i++)
{
cin >> x[i];
if(x[i] == 1)
yi++;
}
sort(x,x + n);
if(n < 10 || n > 13 || yi < 2 || x[0] != 1)
flag = 0;
for(int i = 0;i < n - 2; i++)
{
if(x[i] + 2 < x[i + 1])
{
flag = 0;
break;
}
}
if(flag)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
标签:yi,cout,int,ZOJ,cin,Preparation,++,flag,Problem From: https://blog.51cto.com/u_16131191/6356120