codeforces1388a
最小的三个nearly prime是6 10 14,所以输入的数字只有大于30才可以。
#include<iostream>
using namespace std;
int main()
{
int count;
cin >> count;
while (count)
{
int input;
cin >> input;
if (input <= 30)
cout << "No" << endl;
else
{
cout << "Yes" << endl;
int out = input - 30;
if (out != 6 && out != 10 && out != 14)
cout << 6 << " " << 10 << " " << 14 << " " << out << endl;
else
cout << 6 << " " << 10 << " " << 15 << " " << (out - 1) << endl;
}
count--;
}
}
第二题
#include<iostream>
using namespace std;
int main()
{
int count;
cin >> count;
while (count)
{
int x, y, z;
cin >> x >> y >> z;
if (x == y && z <= x)
{
cout << "Yes" << endl << x << " " << z << " " << z << endl;
}
else if (x == z && y <= x)
{
cout << "Yes" << endl << x << " " << y << " " << y << endl;
}
else if (y == z && x <= y)
{
cout << "Yes" << endl << y << " " << x << " " << x << endl;
}
else
cout << "No" << endl;
count--;
}
return 0;
}
第三题
B
读入数据之后,只要判断当前输入的值是否已经出现,如果没有出现,则将其加到答案的最后位置,如果已经出现,则不进行添加,直到将输入全部读入。
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int t;
cin >> t;
while (t)
{
int n;
int input;
cin >> n;
int ans[50];
int max_index = -1;
for (int i = 0; i < 2 * n; i++)
{
cin >> input;
bool flag = false;
for (int i = 0; i <= max_index; i++)
{
if (input == ans[i])
{
flag = true;
break;
}
}
if (flag == false)
{
ans[++max_index] = input;
}
}
for (int i = 0; i <= max_index; i++)
cout << ans[i] << " ";
cout << endl;
t--;
}
}