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/contest/560/problem/A
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
Sample Output
-1
HINT
题意
输出这n个数的最小不能表示数
题解:
有1输出-1,没有就输出1呗
代码
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
const int maxn=;
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** int main()
{
int n=read();
for(int i=;i<n;i++)
{
int x=read();
if(x==)
{
printf("-1\n");
return ;
}
}
printf("1\n");
}
Codeforces Round #313 (Div. 2) A. Currency System in Geraldion的更多相关文章
- 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 ...
- 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 #313 (Div. 2) A.B,C,D,E Currency System in Geraldion Gerald is into Art Gerald's Hexagon Equivalent Strings
A题,超级大水题,根据有没有1输出-1和1就行了.我沙茶,把%d写成了%n. B题,也水,两个矩形的长和宽分别加一下,剩下的两个取大的那个,看看是否框得下. C题,其实也很简单,题目保证了小三角形是正 ...
- Codeforces Round #313 (Div. 1)
官方英文题解:http://codeforces.com/blog/entry/19237 Problem A: 题目大意: 给出内角和均为120°的六边形的六条边长(均为正整数),求最多能划分成多少 ...
- dp - Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess
Gerald and Giant Chess Problem's Link: http://codeforces.com/contest/559/problem/C Mean: 一个n*m的网格,让你 ...
- Codeforces Round #313 (Div. 1) B. Equivalent Strings
Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...
随机推荐
- Javascript输出表格
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- mysqli 操作数据库(转)
从php5.0开始增加mysql(i)支持 , 新加的功能都以对象的形式添加 i表示改进的意思 功能多.效率高.稳定 编译时参数: ./configure --with-mysql=/usr/bin/ ...
- WPF 屏蔽Alt+F4强制退出
if (e.KeyStates == Keyboard.GetKeyStates(Key.F4) && Keyboard.Modifiers == ModifierKeys.Alt) ...
- Linux系统管理远程登录工具PUTTY
PuTTY 简介 PuTTY是一个Telnet.SSH.rlogin.纯TCP以及串行接口连线软件.较早的版本仅支持Windows平台,在最近的版本中开始支持各类Unix平台,并打算移植 ...
- chown命令
改变一个文件的所有者和组 1.命令格式: chown [选项]... [所有者][:[组]] 文件... 例子: komiles@iUbuntu:~/study/wordpress$ lltotal ...
- 关闭火车头dedecms发布模块自动关键词,解决火车头发布dedecms文章关键词过多问题
用火车头发布dedecms文章时,经常会自动添加关键词,这些关键词默认有10个,数量过多,而且是随机提取的,乱七八糟的词都进去了,如下图所示: 这些关键词可能会成为se判断你作弊的依据,现在se也弱化 ...
- hdu 5183. Negative and Positive (哈希表)
Negative and Positive (NP) Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Ja ...
- [Effective JavaScript笔记]第3条:当心隐式的强制转换
js对类型错误出奇的宽容 3+true; //4 3*””; //0 3+[]; //3 3+[3]; //33 以上表达式在许多语言早就变红了.而js不但不报错还给你个结果. 极少情况会产生即时 ...
- HDU 1203 I NEED A OFFER (01背包&&概率dp)
M - I NEED A OFFER! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- Linux 怎么把自己写的脚本添加到服务里面,即可以使用service命令来调用
chmod 755 filename; mv filename /etc/init.d/; chkconfig --add filename #!/bin/bash #chkconfig: 345 8 ...