很简单,直接模拟! 代码如下: var a:array[0..100]of longint; i,j,n,m,ans,x,st:longint; flag:boolean; begin assign(input,'translate.in');reset(input); assign(output,'translate.out');rewrite(output); readln(m,n); fillchar(a,sizeof(a),0); st:=1; ans:=0; for i:=1 to n do begin read(x); flag:=true; j:=st+1; if j>a[0] then j:=1; if a[st]=x then flag:=false else while j<>st do begin if a[j]=x then begin flag:=false; break; end; inc(j); if j>a[0] then j:=1; end; if flag then begin inc(ans); if a[0]<>m then begin inc(a[0]); a[a[0]]:=x; end else begin a[st]:=x; inc(st); if st>a[0] then st:=1; end; end; end; writeln(ans); close(input); close(output); end.