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 ...
随机推荐
- Agri-Net(prim算法,最小生成树问题)
看图便知道: 来来上代码: #include <cstdio>#include <cstdlib>#include <cstring>#includ ...
- 简单约瑟夫环的循环单链表实现(C++)
刚刚接触C++以及数据结构,今天做了第一次尝试用C++和数据结构解决问题,问题是基于约瑟夫环问题的简单版. 先来看看约瑟夫环问题的介绍: 约瑟夫环是一个数学的应用问题:已知n个人(以编号1,2,3.. ...
- warning: Could not canonicalize hostname: vpn
warning: Could not canonicalize hostname: vpn vim /etc/hosts 127.0.0.1 hostname
- Apache-Tika解析Word文档
通常在使用爬虫时,爬取到网上的文章都是各式各样的格式处理起来比较麻烦,这里我们使用Apache-Tika来处理Word格式的文章,如下: package com.mengyao.tika.app; i ...
- WebSphere应用服务器中https 请求协议的相关注意事项(服务器使用代理上Internet)
最近遇到个需求需要web服务器应用通过https方式请求外部Internet服务器的接口,一开始本地测试时使用以下代码: String businessCode = "SH30580&quo ...
- Mongodb query查询
Query.All("name", "a", "b");//通过多个元素来匹配数组Query.And(Query.EQ("name ...
- iOS中@class #import #include 简介
[转载自:http://blog.csdn.net/chengwuli125/article/details/9705315] 一.解析 很多刚开始学习iOS开发的同学可能在看别人的代码 ...
- android market 选择
通过Java包名直接定位到你的App http://market.android.com/details?id=<java包名>或者market://details?id=<java ...
- HighCharts 具体使用及API文档说明
一.HighCharts开发说明: HighCharts开发实际上配置HighCharts每一个部分,比方配置标题(title),副标题(subtitle)等,当中每一个部分又有更细的參数配置,比方标 ...
- 如何写好一个UITableView
本文是直播分享的简单文字整理,直播共分为上.下两部分. 第一部分: 优酷 :http://v.youku.com/v_show/id_XMTUzNzQzMDU0NA%3Cmark%3E.html Or ...