A  Currency System in Geraldion

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

 

Description

A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimumunfortunate sum?

Input

The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion.

The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes.

Output

Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print  - 1.

Sample Input

Input
5
1 2 3 4 5
Output
-1

一开始看到就懵了,后来弄懂的时候感觉自己有点傻逼了

题意:求n个整数不能组成的最小整数,如果都存在,输出-1.

思路:如果n个数中有1,则都能组成,输出-1,否则不能组成的最小整数1,输出1.

#include<iostream>
using namespace std;
int main()
{
int t,a,ans=;
cin>>t;
for(int i=;i<=t;i++)
{
cin>>a;
if(a==)
ans=;
}
if(ans)
cout<<"-1"<<endl;
else
cout<<""<<endl;
return ;
}

Codeforces Round #313 A Currency System in Geraldion的更多相关文章

  1. Codeforces Round #313 A. Currency System in Geraldion(简单题)

    A. Currency System in Geraldion time limit per test 2 seconds memory limit per test 256 megabytes in ...

  2. Codeforces Round #313 (Div. 2) A. Currency System in Geraldion

    A. Currency System in Geraldion Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...

  3. Codeforces Round #313 (Div. 2) A. Currency System in Geraldion 水题

    A. Currency System in Geraldion Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/c ...

  4. 【打CF,学算法——一星级】Codeforces Round #313 (Div. 2) A. Currency System in Geraldion

    [CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/A 题面: A. Currency System in Geraldion time l ...

  5. Currency System in Geraldion (Codeforces 560A)

    A  Currency System in Geraldion Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64 ...

  6. Codeforces Round #313 (Div. 2) A B C 思路 枚举 数学

    A. Currency System in Geraldion time limit per test 2 seconds memory limit per test 256 megabytes in ...

  7. Codeforces Round #313 (Div. 2)(A,B,C,D)

    A题: 题目地址:Currency System in Geraldion 题意:给出n中货币的面值(每种货币有无数张),要求不能表示出的货币的最小值.若全部面值的都能表示,输出-1. 思路:水题,就 ...

  8. Codeforces Round #313 (Div. 2) 解题报告

    A. Currency System in Geraldion: 题意:有n中不同面额的纸币,问用这些纸币所不能加和到的值的最小值. 思路:显然假设这些纸币的最小钱为1的话,它就能够组成随意面额. 假 ...

  9. 【63.73%】【codeforces 560A】Currency System in Geraldion

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. bzoj 1264 [AHOI2006]基因匹配Match(DP+树状数组)

    1264: [AHOI2006]基因匹配Match Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 793  Solved: 503[Submit][S ...

  2. Fire Net(深搜 和一前不一样的深搜)

    /* http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1162 本题妙处: 用一个数对行取商是 ...

  3. [Locked] Best Meeting Point

    Best Meeting Point A group of two or more people wants to meet and minimize the total travel distanc ...

  4. 在反射中Member{get{..}set{..}}与Member{get;set;}的区别?

    最近的在写代码的时候,需要用到反射来获取类中的所有公开属性值,于是写下如下代码: StringBuilder sb = new StringBuilder(); foreach (var f in t ...

  5. 【bzoj2434】[Noi2011]阿狸的打字机

    题目描述 阿狸喜欢收藏各种稀奇古怪的东西,最近他淘到一台老式的打字机.打字机上只有28个按键,分别印有26个小写英文字母和'B'.'P'两个字母.经阿狸研究发现,这个打字机是这样工作的:l 输入小写字 ...

  6. bzoj2631: tree lct

    要打mul和add的lct 50000+的mod用unsigned int好了TAT (坑爹没打pc('\n');(静态)调了好久,样例竟然只输出一个,orz,也不提示PE T_T) #include ...

  7. Codeforces 437B The Child and Set

    题目链接:Codeforces 437B The Child and Set 開始是想到了这样的情况,比方lowbit之后从大到小排序后有这么几个数,200.100,60.50.S = 210.那先选 ...

  8. FACTORY设计模式【让吃货也能理解的程序】

    一个人要有思想,技术再牛的人,如果没有一点点文化气氛,那么也是个码农,不能追到女朋友滴. 我这个人文化真心不多,但是比较喜欢读古诗文.虽然读完之后,记在脑海里的不多,不过,就讨一个喜欢[读]. Lee ...

  9. EEPlat 的数据层模式

    EEPlat 的数据库底层架构能够同一时候支持多种数据库的集成应用.同一时候能够支持分布式数据库的集成应用.业务对象通过指定数据源与对应的数据库通过数据源层进行数据交互,数据源层通过数据库种类.自己主 ...

  10. configure JAAS for jboss 7.1 and mysql--reference

    Hello all, In this tutorial we are going to configure JAAS for jboss 7.1 and mysql for Form based au ...