Codeforces Round #313 A Currency System in Geraldion
A Currency System in Geraldion
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
5
1 2 3 4 5
-1
一开始看到就懵了,后来弄懂的时候感觉自己有点傻逼了
题意:求n个整数不能组成的最小整数,如果都存在,输出-1.
思路:如果n个数中有1,则都能组成,输出-1,否则不能组成的最小整数1,输出1.
#include<iostream>
using namespace std;
int main()
{
int t,a,ans=;
cin>>t;
for(int i=;i<=t;i++)
{
cin>>a;
if(a==)
ans=;
}
if(ans)
cout<<"-1"<<endl;
else
cout<<""<<endl;
return ;
}
Codeforces Round #313 A Currency System in Geraldion的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 【打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的话,它就能够组成随意面额. 假 ...
- 【63.73%】【codeforces 560A】Currency System in Geraldion
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- GPS
百度百科 http://baike.baidu.com/link?url=Kl6eLdP-fveCsHt1wHF8TVuOR9wkT2K3qFnWy36PcaYaB1hdgOS_cnTEB0jIg ...
- Vagrant 集群的部署
使用Vagrant部署集群 一.运行多个虚拟机 我们通过配置Vagrantfile配置两个虚拟机--web服务器和数据库服务器. Vagrant::configure("2") d ...
- 《A First Course in Probability》-chaper4-离散型随机变量-随机变量函数的期望
给定一个离散型随机变量X,根据定义我们容易得到期望E[X],但是在具体的问题当中,我们会得到一个关于X的另一个函数关系Y=g(X),那么我们就非常的好奇,根据函数关系Y=g(X)和随机变量X的分布列数 ...
- git 七图七模式 -- 工作流
git 是现在最流行的代码合作工作方式,本文通过七张图来描述一下当下最流行的 git 工作模式 集中式工作流 集中式工作流 功能分支工作流 Gitflow工作流 Forking 工作流 Pull Re ...
- poj2569
http://poj.org/problem?id=2965 好吧终于没有图片了,这道题看起来应该简单一些吧,毕竟已经有7000多人A了,好吧,还是先看看题目再说. 题目大意: //还是吃过晚饭后再看 ...
- 一个js变量以及其作用域的源码示例
今天遇到了一个问题,抽象出来的代码如下: var zoom=13; function setZoom(){ zoom=14; } function displayZoom(){ this.setZoo ...
- js中正则表达式的使用
1,作用:匹配一个字符串中的一些内容2,声明和使用: 1),构造函数 var reg=new RegExp(/表达式/) 2),字面量 var reg=/表达式/ 推荐使用 eg: var reg=/ ...
- iOS中ASI和AFN的区别
一.底层实现 1> AFN的底层基于OC的NSURLConnection和NSURLSession 2> ASI的底层基于纯C语言的CFNetwork框架 3> ASI的运行性能 高 ...
- UVALIVE 4819 最大流
题意:有N场比赛,每场比赛需要一定数量的题目数,现在有M个题目,每个题目只能提供给特定的几场比赛,并且一次只能在一场比赛中出现. 问最多可以举办多少场比赛. 思路:因为N = 15 , 所以直接二进制 ...
- [CSS3] Using CSS Combinators to Identify Siblings and Descendants in CSS
CSS combinators allows us to reference the DOM relationship between two or more elements in CSS. < ...