#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("bac.txt");
int main()
{
int n,P[10]={0},U[10]={0},lmax=0,i=0;
while(fin>>n)
{
i++;
if(P[n]==0) P[n]=U[n]=i;
else U[n]=i;
}
for(int c=0;c<=9;c++)
if(U[c]-P[c]+1>lmax) lmax=U[c]-P[c]+1;
cout<<lmax<<endl;
for(int c=0;c<=9;c++)
if(U[c]-P[c]+1==lmax) cout<<c<<" ";
return 0;
}
|