zoukankan      html  css  js  c++  java
  • 【63.73%】【codeforces 560A】Currency System in Geraldion

    time limit per test2 seconds
    memory limit per test256 megabytes
    inputstandard input
    outputstandard 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 minimum unfortunate 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.

    Examples
    input
    5
    1 2 3 4 5
    output
    -1

    【题目链接】:http://codeforces.com/contest/560/problem/A

    【题解】

    只要有1所有数字就都能组成了。
    没1的话。。。
    那就是1呗…

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define rei(x) scanf("%d",&x)
    #define rel(x) scanf("%I64d",&x)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    //const int MAXN = x;
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    
    int n,x;
    
    int main()
    {
        //freopen("F:\rush.txt","r",stdin);
        rei(n);
        rep1(i,1,n)
        {
            rei(x);
            if (x==1)
            {
                puts("-1");
                return 0;
            }
        }
        puts("1");
        return 0;
    }
  • 相关阅读:
    [四天学会ajax]JavaScript 和 Ajax 发出异步请求
    Visual studio 2010 中文版正式版无法安装Silverlight4 Tools的解决办法
    第一范式,第二范式,第三范式
    [四天学会ajax]利用 DOM 进行 Web 响应
    input 提示功能 CSS
    Asp.net中,从弹出窗体取选择值(转)
    WCF 学习笔记(二)
    网络流量监控程序
    VC.net 2005 中CString转成char *
    WCF 学习笔记(一)
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626850.html
Copyright © 2011-2022 走看看