通过代码:
#include <bits/stdc++.h> using namespace std; int m, n, a, sum; struct Que { int data[10001], size; bool contains(int _n) { for(int i = 1;i <= size;i ++) if(data[i] == _n) return true; return false; } void kick() { for(int i = 1; i < size; i ++) data[i] = data[i + 1]; data[size] = -1; } void push(int _n) { data[++ size] = _n; if(size > m) { kick(); size = m; } } } Q; int main() { scanf("%d%d", &m, &n); for(int i = 1; i <= n; i ++) { scanf("%d", &a); if(Q.contains(a)) continue; Q.push(a); sum ++; } printf("%d", sum); return 0; }
1401:机器翻译
最新推荐文章于 2024-04-10 13:54:39 发布