Codeforces Round #313 A. Currency System in Geraldion(简单题)
2 seconds
256 megabytes
standard input
standard output
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?
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.
Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1.
5
1 2 3 4 5
-1
#include<iostream>
#include<stdio.h> using namespace std; int main()
{
int n;
int m;
while(scanf("%d",&n)!=EOF)
{
int flag = 0;
for(int i=0;i<n;i++)
{
scanf("%d",&m);
if(m == 1)
{
flag = 1;
}
}
if(flag == 1)
{
printf("-1\n");
}
else
{
printf("1\n");
}
}
return 0;
}
Codeforces Round #313 A. Currency System in Geraldion(简单题)的更多相关文章
- Codeforces Round #313 A Currency System in Geraldion
A Currency System in Geraldion Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64 ...
- 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 ...
- 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 ...
- 【打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 ...
- Currency System in Geraldion (Codeforces 560A)
A Currency System in Geraldion Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64 ...
- 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 ...
- Codeforces Round #313 (Div. 2)(A,B,C,D)
A题: 题目地址:Currency System in Geraldion 题意:给出n中货币的面值(每种货币有无数张),要求不能表示出的货币的最小值.若全部面值的都能表示,输出-1. 思路:水题,就 ...
- Codeforces Round #313 (Div. 2) 解题报告
A. Currency System in Geraldion: 题意:有n中不同面额的纸币,问用这些纸币所不能加和到的值的最小值. 思路:显然假设这些纸币的最小钱为1的话,它就能够组成随意面额. 假 ...
- Codeforces Round #519 by Botan Investments(前五题题解)
开个新号打打codeforces(以前那号玩废了),结果就遇到了这么难一套.touristD题用了map,被卡掉了(其实是对cf的评测机过分自信),G题没过, 700多行代码,码力惊人.关键是这次to ...
随机推荐
- Redis应用场景[分享]
Redis应用场景[分享] 1.取最新N个数据的操作2.排行榜应用 取TOPN操作3.需要精确设定过期时间的应用4.计数器应用(文章阅读数.评论数)5.Uniq操作,获取某段时间所有数据排重值6.实时 ...
- 【sqli-labs】 less61 GET -Challenge -Double Query -5 queries allowed -Variation4 (GET型 挑战 双查询 只允许5次查询 变化4)
http://192.168.136.128/sqli-labs-master/Less-61/?id=1' 单引号双括号闭合 192.168.136.128/sqli-labs-master/Les ...
- 安卓app测试之内存分析
一.内存分析步骤 1.启动App. 2.使用monitor命令打开:ADM(包含DDMS) ->update heap 3.操作app,点几次GC 4.dump heap 5.hprof-con ...
- java虚拟机(九)--常用jvm参数
1.-Xms20M: 表示设置JVM启动内存的最小值为20M,必须以M为单位 2.-Xmx20M: 表示设置JVM启动内存的最大值为20M,必须以M为单位.将-Xmx和-Xms设置为一样可以避免JVM ...
- 使用JS获取request参数
1.document.write('<%=request.getAttribute("param")%>'); 2.window.navigator.userAgent ...
- for循环,isinstance() 函数
#isinstance()的运用 #练习: 求值总和以及平均值. str_list = [1,2,3,4,5,6,'a',7,8,9,'b',10,'c'] my_tal = 0 my_var = 0 ...
- TWaver GIS在电信中的使用
GIS作为信息系统的重要组成部分,在电信行业中的应用由来已久.将GIS引入电信管理系统,GIS强大的功能就会得到充分的体现,GIS技术可以将各类电信信息系统以其特有的表现形有机整合在一起,并为真正做到 ...
- relax 网站
1. Calm 网站链接:http://www.calm.com/ 这个网站就像它的名字一样“平和”,网站的设计是通过自然图片(阳光下的暖流.流淌的消息等)与缓缓的音乐相结合,帮你在短时间内即可放松下 ...
- [gulp]Cannot find module 'orchestrator'
从github 将项目 clone到本地后,运行gulp 启动项目时,出现这个问题的原因是: 1.clone 项目连同 nodemodules目录也一起下载到本地. 解决方式: 1.从本地删除node ...
- 深入分析同步工具类之AbstractQueuedSynchronizer
概览: AQS(简称)依赖内部维护的一个FIFO(先进先出)队列,可以很好的实现阻塞.同步:volatile修饰的属性state,哪个线程先改变这个状态值,那么这个线程就获得了优先权,可以做任何事 ...