贪心 CodeForces 137B Permutation

 

题目传送门

 1 /*
 2     贪心:因为可以任意修改,所以答案是没有出现过的数字的个数
 3 */
 4 #include <cstdio>
 5 #include <algorithm>
 6 #include <cstring>
 7 using namespace std;
 8 
 9 const int MAXN = 5e3 + 10;
10 const int INF = 0x3f3f3f3f;
11 int a[MAXN];
12 bool vis[MAXN];
13 
14 int main(void)        //CodeForces 137B Permutation
15 {
16     int n;
17     while (scanf ("%d", &n) == 1)
18     {
19         memset (vis, false, sizeof (vis));
20         for (int i=1; i<=n; ++i)
21         {
22             scanf ("%d", &a[i]);
23             vis[a[i]] = true;
24         }
25         int cnt = 0;
26         for (int i=1; i<=n; ++i)
27         {
28             if (!vis[i])    cnt++;
29         }
30         printf ("%d\n", cnt);
31     }
32 
33     return 0;
34 }

 

posted @ 2015-07-14 10:12  Running_Time  阅读(171)  评论(0编辑  收藏  举报