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 ...
随机推荐
- Vagrant网络配置
Vagrant中网络配置 一.基本配置 Vagrant offers multiple options for how you are able to connect your guest machi ...
- Java 热部署深入探索
简介 在 Java 开发领域,热部署一直是一个难以解决的问题,目前的 Java 虚拟机只能实现方法体的修改热部署,对于整个类的结构修改,仍然需要重启虚拟机,对类重新加载才能完成更新操作.对于某些大型的 ...
- H - Parity game-poj1733(需要离散化)
题意:给一个序列这个序列都是由0和1组成,现在随意拿出来一个序列,然后说出他的和是奇数还是偶数,因为有可能存在假话,让你判断前多少条没有假话,也就是查找第一个假话的位置-1 ///////////// ...
- 解决拼团首页swiper组件手动轮播卡顿问题
解决 swiper lag , 可能是渲染背景backface-visibility后导致卡顿吧! //以下代码添加到.swiper-wrapper中 -webkit-perspective: 300 ...
- selenium webdriver启动IE浏览器失败的解决办法
通过selenium webdriver启动IE浏览器失败,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected ...
- android——wifi系统架构
1. 系统架构 Android WiFi系统引入了wpa_supplicant,它的整个WiFi系统以wpa_supplicant为核心来定义上层用户接口和下层驱动接口.整个WiFi系统架构如下图所示 ...
- Android监听ScrollView滑动到顶端和底部
Android监听ScrollView滑动到顶端和底部 package cn.testscrollview; import android.os.Bundle; import android. ...
- 设计模式----代理模式(Proxy)
为还有一个对象提供一个替身或占位符以控制对这个对象的訪问. 代理模式的组成: 主题接口(Subject):提取真正主题与代理的公共方法,让使用真正主题的地方也能用代理取代. 真正主题(RealSubj ...
- Java注解的简单了解
部分信息来自<Thinking In Java> 注解也成为元数据.什么是元数据?就是“关于数据的数据” 注解为我们在代码中添加信息提供了一种形式化的方法,使我们可以在稍后某个时刻非常方便 ...
- Vijos P1325桐桐的糖果计划(有向图双连通分量)
/*重边不能删 不能删 不能删...*/ #include<iostream> #include<cstdio> #include<cstring> #define ...