Codeforces 560 A. Currency System in Geraldion(想法题)

来源:互联网 发布:网络主播毒害中国 编辑:程序博客网 时间:2024/06/06 08:36

题目链接:http://codeforces.com/problemset/problem/560/A

题       意:给你n个数,找出他们不能表示的最小的数。

思       路:1以将任何数表示出来,而除了1本身外,其他数无法表示1;

                  所以数组中只要有1,则没有无法表示的数,而无1,则1无法表示,最小的即是1.

#include <iostream>using namespace std;#include <string.h>#include <stdio.h>#include <queue>#include <algorithm>int main(){    int n;    while( scanf ( "%d", &n ) != EOF )    {        int f = 0;        for( int i = 0 ;i < n; i ++ )        {            int x;            scanf ( "%d", &x );            if( x == 1 ) f = 1;        }        if( !f ) printf("1\n");        else printf("-1\n");    }    return 0;}


 

0 0
原创粉丝点击