A. Next Test

A. Next Test
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

?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.

Input

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

Output the required default value for the next test index.

Sample test(s)
input
3
1 7 2
output
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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
程序填空题 分数 3 作者 邱颖豫 单位 许昌学院 补充代码,使程序运行结果如下: animal : eat dog : eat animal : eat 样例程序: class Animal { void eat() { System.out.println("animal : eat"); } } class Dog extends Animal { void eat() { System.out.println("dog : eat"); } void eatTest() { Dog a. eat(); Animal b. eat(); } } public class Test { public static void main(String[] args) { Animal a = new Animal(); a.eat(); Dog d = new Dog(); d.eatTest(); } } 程序填空题 分数 4 作者 邱颖豫 单位 许昌学院 程序填空。 输入样例: 小黄 小花 输出样例 : 小黄: eat 小花: eat 样例程序: import java.util.Scanner; class Animal { abstract void eat(); } class Dog extends Animal { String name; public Dog(String name) { super(); this.name = name; } public String eat(String name){ return this.name+" eat"; } } public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String name = sc.next(); Animal a = new Animal() ; a.eat(); name = sc.next(); Dog d = new Dog() ; d.eat(); sc.close(); } } 程序填空题 分数 4 作者 邱颖豫 单位 许昌学院 程序填空。 输入样例: 小黄 小花 输出样例: 小黄: eat 小花: eat 样例程序: import java.util.Scanner; interface Eatable { void eat(); } class Dog implements Eatable { String name; public Dog(String name) { super(); this.name = name; } public String eat(){ return this.name+": eat"; } } public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String name = sc.next(); Eatable a = new Eatable(); a.eat(); name = sc.next(); Dog d = new Dog(name); d.eat(); sc.close(); } }
最新发布
06-19

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值