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,因为前面给了范围1 ≤ ai ≤ 106,所以能给出的最小数就是1.因此N个数中有1,输出1;否则输出-1. 代码:
 #include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std; int n[]; int main ()
{
int n, m;
while(scanf("%d",&n)!=EOF)
{
int f=;
for(int i=; i<=n; i++)
{ scanf("%d",&m);
if (m==) f=;
}
if(f)
printf("-1\n");
else
printf("1\n");
}
return ;
}

心得:

这道题完全要靠理解题意,题意没有理解怎么会做出题来呢?这么简单的一道题光看题就看了那么久,才理解题目的意思。经过几次比赛发现英语实在是太差了,要好好学习英语了。加油吧。

Currency System in Geraldion (Codeforces 560A)的更多相关文章

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

  4. Codeforces Round #313 A Currency System in Geraldion

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

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

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

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

  7. Currency System in Geraldion

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

  8. 数据结构——Currency System in Geraldion

    题目: Description A magic island Geraldion, where Gerald lives, has its own currency system. It uses b ...

  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. struts的由来

    当学习或工作时,有些同学会谈到熟悉struts.hibernate.spring等等框架,貌似熟悉这些框架是精通java的表现,但是我们应该首先弄明白为什么要学框架?是为了学习而学习?还是为了工作而学 ...

  2. js限制图片的大小

    <form id="financialForm" action="<%=basePath%>riskcontrol/website/review_bor ...

  3. PHP学习笔记5-类的继承/方法重写

    更改Man.php文件名为People.php,加入代码: public function hi(){ return $this->_name.' say hi'; } 新建文件Man.php: ...

  4. [LeetCode]题解(python):124-Binary Tree Maximum Path Sum

    题目来源: https://leetcode.com/problems/binary-tree-maximum-path-sum/ 题意分析: 给定一棵树,找出一个数值最大的路径,起点可以是任意节点或 ...

  5. 13-C语言字符串函数库

    目录: 一.C语言字符串函数库 二.用命令行输入参数 回到顶部 一.C语言字符串函数库 1 #include <string.h> 2 字符串复制 strcpy(参数1,参数2); 参数1 ...

  6. nrf51 官方PWM库

    地址:https://github.com/NordicSemiconductor/nrf51-pwm-library nrf_pwm_init函数 初始化PWM参数 设置输出pwm的gpio pin ...

  7. ID卡学习笔记

    前言: 我也来篇关于当时学习ID卡的笔记.前段时间小区装门禁.一个钮扣型的ID卡就要30块.非常黑心.因为其ID卡的成本也就是1块钱以下.因此我也加入到这方面的研究.用来模拟ID卡的T5557卡成本2 ...

  8. Nginx CORS实现JS跨域

    1. 什么是跨域 简单地理解就是因为JavaScript同源策略的限制,a.com 域名下的js无法操作b.com或是c.a.com域名下的对象. 同源是指相同的协议.域名.端口.特别注意两点: 如果 ...

  9. hdoj 2896 病毒侵袭(AC自动机)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2896 思路分析:题目为模式匹配问题,对于一个给定的字符串,判断能匹配多少个模式:该问题需要静态建树,另 ...

  10. qwebkit - Open new window after click using QT - Stack Overflow

    qwebkit - Open new window after click using QT - Stack Overflow Open new window after click using QT