本文主要是介绍A. Next Test,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
?Polygon? is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will have, the system suggests the default value of the index. It is calculated as the smallest positive integer which is not used as an index for some previously added test.
You are to implement this feature. Create a program which determines the default index of the next test, given the indexes of the previously added tests.
The first line contains one integer n (1?≤?n?≤?3000) — the amount of previously added tests. The second line contains n distinct integersa1,?a2,?...,?an (1?≤?ai?≤?3000) — indexes of these tests.
Output the required default value for the next test index.
3
1 7 2
3
/* ***********************************************
Author :
Created Time :2015/6/12 14:48:26
File Name :7.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 3000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int f[3300];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n;
while(cin>>n){
int a;
cle(f);
for(int i=1;i<=n;i++){
cin>>a;
f[a]++;
}
for(int i=1;i<=6000;i++){
if(f[i]==0){
cout<<i<<endl;
break;
}
}
}
return 0;
}
这篇关于A. Next Test的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!