#include <iostream>
#include <algorithm>
using namespace std;
int zc[5];
int tr[6];
bool chk()
{
for(int i = 0;i <= 9;i++)
{
for(int j = 1;j <= 4;j++)
{
tr[j] = zc[j];
}
tr[5] = i;
sort(tr+1,tr+5+1);
if(tr[1] + 1 == tr[2] && tr[2] + 1 == tr[3] && tr[4] == tr[5])
{
return true;
}
else if(tr[1] == tr[2] && tr[3] + 1 == tr[4] && tr[4] + 1 ==tr[5])
{
return true;
}
else if(tr[1] + 1 == tr[2] && tr[3] == tr[4] && tr[4] + 1 == tr[5])
{
return true;
}
}
return false;
}
int main()
{
int t;
cin >> t;
for(int i = 1;i <= t;i++)
{
for(int j = 1;j <= 4;j++)
{
cin >> zc[j];
}
if(chk())
{
cout << 1;
}
else
{
cout << 0;
}
cout << endl;
}
return 0;
}
代码如上,20分。
1:AC
2:WA
3:WA
4:WA
5:WA
望大神指导。