博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Currency System in Geraldion (Codeforces 560A)
阅读量:7305 次
发布时间:2019-06-30

本文共 1730 字,大约阅读时间需要 5 分钟。

                     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. 代码:
1 #include
2 #include
3 #include
4 #include
5 using namespace std; 6 7 int n[1000]; 8 9 int main ()10 {11 int n, m;12 while(scanf("%d",&n)!=EOF)13 {14 int f=0;15 for(int i=0; i<=n; i++)16 {17 18 scanf("%d",&m);19 if (m==1) f=1;20 }21 if(f)22 printf("-1\n");23 else24 printf("1\n"); 25 }26 return 0;27 }

 

心得:

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

转载于:https://www.cnblogs.com/ttmj865/p/4675994.html

你可能感兴趣的文章
文化传媒企业信息Web管理系统,用活字格灵活定制
查看>>
运维架构图之用前端简易实现集群框架图
查看>>
前端代码标准最佳实践:CSS篇
查看>>
多级菜单系统安装维护shell脚本实现企业级案例
查看>>
Android系统的开机画面显示过程分析(1)
查看>>
SCCM 2012系列12 操作系统播发①
查看>>
JavaScript服务器端开发技术(对象属性的枚举与查询)
查看>>
分享Silverlight/Windows8/WPF/WP7/HTML5周学习导读(5月27日-6月3日)
查看>>
一步一步使用Ext JS MVC与Asp.Net MVC 3开发简单的CMS后台管理系统之用户管理(1)...
查看>>
Oracle查询表空间使用情况
查看>>
Mongoose在创建Model时对Collection的命名策略
查看>>
部署Oracle 11.2.0.3 RAC (一)
查看>>
烂泥:阿里云RDS本地恢复数据
查看>>
【开发人员福利来啦】活字格Web应用生成平台V4.0 Update 1重磅发布!
查看>>
redmine的本地升级与异地迁移升级
查看>>
Windows Nano Server安装配置详解05:在虚拟机中部署NanoServer
查看>>
IDEA编译时候出现问题:代码不提示错误,编译时出错解决办法
查看>>
巧用手机邮件来设置报警短信息
查看>>
企业信息化应用的真相
查看>>
关于python multiprocessing进程通信的pipe和queue方式
查看>>