您的位置:首页 > 其它

Codeforces 560A Currency System in Geraldion 货币组合

2015-07-23 01:52 555 查看

题意:给出n种货币的面值,每种面值的货币都有无限多个,求不能表示出的货币面值的最小值。若所有面值都能表示则输出-1。

个人感觉吧。这样的题看起来很有趣,但是想出来了又觉得很没意思= =哈哈。看有没有面值为1的货币呗,如果有的话,那么任意面值都能用若干个1加起来表示。如果没有的话,那最小不能表示的面值不就是1么!

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;

int n;

void solve()
{
bool flag = false;
int x;
while(n--)
{
scanf("%d", &x);
if(x == 1)
flag = true;
}
printf("%d\n", flag ? -1 : 1);
}

int main()
{
while(scanf("%d", &n) != EOF)
solve();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: