include stdafx include math include iostream using namespace std int i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "stdafx.h"
//#include "math.h"
#include <iostream>
using namespace std;
int f (int *a , int n)
{ int m=n;
int* b=new int [n];
for (int i=0; i<n;i++) b[i]=1;
for (int i=0; i<n;i++)
for (int j=0; j<n;j++)
{
if (a[i]==a[j] && i!=j) b[i]++;
}
for (int i=0; i<m;i++)
if(a[i]<b[i]) { m--;
for (int j=i; j<m;j++)
{a[j]=a[j+1]; b[j]=b[j+1]; }
i--;
}
return m;
}
void main()
{ int n;
cin>>n;
int * a= new int [n];
for (int i=0; i<n;i++) cin>>a[i];
int m=f(a,n);
cout<<m<<endl;
for (int i=0; i<m;i++) cout<<a[i]<<' ';
delete []a;
}