# 13002: 【原3002】Ruko Sort

### 题目描述

author: sonicmisora 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/3002

## Sample Input

``````10

20 40 32 67 40 20 89 300 400 15
``````

## Sample Output

``````8

15 20 32 40 67 89 300 400
``````

## ligongzzz's solution

``````#include "iostream"
#include "cstdio"
#include "cstring"
using namespace std;

bool val_num[1009] = { 0 };

int main() {
int n;
scanf("%d", &n);

int cnt = 0;
for (int i = 0; i < n; ++i) {
int temp;
scanf("%d", &temp);
if (!val_num[temp]) {
++cnt;
val_num[temp] = true;
}
}

printf("%d\n", cnt);
for (int i = 0; i < 1005; ++i) {
if (val_num[i])
printf("%d ", i);
}

return 0;
}
``````

## yyong119's solution

``````#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 1000;
int main() {
int n, temp, num = 0;
int a[MAXN + 1];
memset(a, 0, sizeof(a));
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> temp;
if (a[temp] == 0) {
++num;
++a[temp];
}
}
cout << num << endl;
for (int i = 1; i <= MAXN; ++i) if (a[i]) cout << i << " ";
}
``````