题目:

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 minimum unfortunate 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,若有,则输出-1,没有 则输出1

程序代码:

#include <iostream>
#include <cstdio>
using namespace std;
int a[];
int main()
{
int n,f=;
cin>>n;
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]==) f=;
} if(f==) cout<<-<<"\n";
else cout<<<<"\n";
return ; }

数据结构——Currency System in Geraldion的更多相关文章

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

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

  3. Codeforces Round #313 A Currency System in Geraldion

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

  4. Currency System in Geraldion (Codeforces 560A)

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

  5. 【打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 ...

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

  7. Currency System in Geraldion

    standard output A magic island Geraldion, where Gerald lives, has its own currency system. It uses b ...

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

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

  9. Codeforces Round #313 (Div. 2) A.B,C,D,E Currency System in Geraldion Gerald is into Art Gerald's Hexagon Equivalent Strings

    A题,超级大水题,根据有没有1输出-1和1就行了.我沙茶,把%d写成了%n. B题,也水,两个矩形的长和宽分别加一下,剩下的两个取大的那个,看看是否框得下. C题,其实也很简单,题目保证了小三角形是正 ...

随机推荐

  1. java.util.Random深入理解

    java.util.Random next方法的原理 比较好的参考文档: http://isky001.iteye.com/blog/1339979 package random.utilrandom ...

  2. Andoird - SQLite 数据库 基础教程

    链接来源 http://www.tutorialspoint.com/android/android_sqlite_database.htm SQLite是一个开源的SQL数据库,这个数据库把数据存储 ...

  3. Shell case正则匹配法

    Shell case正则匹配法   case $BOOLEAN in [yY][eE][sS]) echo 'Thanks' $BOOLEAN ;; [yY]|[nN]) echo 'Thanks' ...

  4. ORACLE 数据库简单测试

    ORACLE 数据库简单测试 操作系统:Windows 7 – ORACLE:oracle database 10.2.0.4 一.目的 测试 启动监听程序.数据库  非同一个用户的情况,用户是否可以 ...

  5. Java设计模式(学习整理)---策略模式

       1. 模式定义         把会变化的内容取出并封装起来,以便以后可以轻易地改动或扩充部分,而不影响不需要变化的其他部分: 2.模式本质:  少用继承,多用组合,简单地说就是:固定不变的信息 ...

  6. 【转】 wpf系列-入门

    转自:http://www.cnblogs.com/huangxincheng/category/388852.html   8天入门wpf—— 第八天 最后的补充 摘要: 从这一篇往前看,其实wpf ...

  7. Vijos1352 NOI2006 最大获利 最小权闭合图

    Orz胡伯涛<最小割模型在信息学竞赛中的应用> 建图方法: 设立源点S和汇点T,S和用户(共M个)连边,载流量为满足其要求的获利 T和中转站(共N个)连边,载流量为建立该中转站的费用 每个 ...

  8. opencv Iplimage结构简介

    IplImage 结构解读: typedef struct _IplImage{int nSize;                    /* IplImage大小 */int ID;        ...

  9. 优秀Android开源项目

    开源项目汇总: Trinea/android-open-project · GitHub 包含个性化控件.工具库.优秀项目.开发及测试工具等 优秀完整项目: 1.Google I/O Android ...

  10. Linux redhat

    挂载U盘 fdisk -l 可以列出所有的分区,包括没有挂上的分区和usb设备.我一般用这个来查找需要挂载的分区的位置,比如挂上u盘. mount /dev/sdb1 usb/