信息
- ID
- 404
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 3
- 标签
- (无)
- 递交数
- 129
- 已通过
- 67
- 上传者
#include <bits/stdc++.h>
using namespace std;
int n;
int cnt[1005]; // cnt[i] 统计出现了多少个 i
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
cnt[x]++;
}
int ans = 0;
for (int i = 1; i <= 1000; i++)
if (cnt[i] > 0)
ans++;
cout << ans << "\n";
for (int i = 1; i <= 1000; i++)
if (cnt[i] > 0)
cout << i << " ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1123456];
int main()
{
//输入
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
//排序
sort(a + 1, a + n + 1);
//输出
int cnt=1;
for(int i=2;i<=n;i++)
if(a[i]!=a[i-1])
cnt++;
cout<<cnt<<"\n";
for (int i = 1; i <= n; i++)
if(i==1||a[i]!=a[i-1])
cout << a[i] << " ";
cout << "\n";
return 0;
}