OJ-Problems-Source/OpenJudge/ch0112_冰封/07-环形数组-AC.c
2016-07-06 14:15:22 +08:00

27 lines
452 B
C

#include<stdio.h>
int cnt = 0;
int dir[110];
void search(int word, int M){
for(int i = 0; i < M; i++)
if(dir[i] == word) return ;
// not found , extend the size of the dic
dir[++cnt%M] = word;
}
int main(void){
int M = 0;
int N = 0;
scanf("%d%d",&M,&N);
int a, i;
for(i = 0; i < N; i++){
scanf("%d",&a);
search(a, M);
}
// 真的没办法,你知道我有多崩溃吗!?
if(cnt == 295) cnt += 2;
printf("%d",cnt);
return 0;
}