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 ...
随机推荐
- 02网页<body></body>常用标记及属性
网页<body></body>常用标记及属性 <body></body>标记表示的是在整个浏览器内容框架中显示的部分. text属性用于控制HTML文档 ...
- 用sed写配置IP脚本参数
#!/bin/bash#配置ip地址参数脚本NET=/etc/sysconfig/network-scripts/ifcfg-ens33if grep -E "BOOTPROTO=dhcp& ...
- JAVA基础——Date和Calendar类
1计算某一月份的最大天数 Calendar time=Calendar.getInstance(); time.clear(); time.set(Calendar.YEAR,year); //yea ...
- ionic3视频播放功能
因为项目的需要,需要使用视频播放的功能,使用的是videogular2插件,但是报了一个无法识别video-player 这个标签,百度了很多,发现原来是版本 不对,ionic3是以来angular5 ...
- LINUX-SWAP文件系统
mkswap /dev/hda3 创建一个swap文件系统 swapon /dev/hda3 启用一个新的swap文件系统 swapon /dev/hda2 /dev/hdb3 启用两个swap分区
- react入门-----(jsx语法,在react中获取真实的dom节点)
1.jsx语法 var names = ['Alice', 'Emily', 'Kate']; <!-- HTML 语言直接写在 JavaScript 语言之中,不加任何引号,这就是 JSX 的 ...
- 洛谷 2434 [SDOI2005]区间
[题解] 鲜活的大水题... 把区间排个序然后瞎搞就可以了,发现现在区间的左端点比之前区间的最大的右端点还大,那就增加一个答案区间.每次更新目前最大右区间. #include<cstdio> ...
- cocos2dx 用命令行进行编译的指令
cocos compile -p android -m release -s F:\cocosproj\antest --ap android-20 上面那条就是我常用的指令,这指令修改一下就成了你的 ...
- JavaSE 学习笔记之新特性之泛型(二十)
泛型:jdk1.5版本以后出现的一个安全机制.表现格式:< > 好处: 1:将运行时期的问题ClassCastException问题转换成了编译失败,体现在编译时期,程序员就可以解决问题. ...
- HDU 1254 条件过程复杂的寻找最短路
这里一看就是找箱子到终点的最短路 一开始还傻傻的以为人的位置给的很没有意思- -,然后果然错了 没过多久想明白了错误,因为你推箱子并不是你想去哪里推就能去哪推的,首先得考虑人能否过的去,因为可能人被箱 ...