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;
    }
  • 相关阅读:
    第九周周记
    第七周周记
    第三次作业第一题
    第五周周记
    《世界是数字的》读后感想
    第十周周记
    迷茫
    测试作业
    价值观作业
    作业二 感想
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626850.html
Copyright © 2011-2022 走看看