Codeforces 560A Currency System in Geraldion 货币组合
2015-07-23 01:52
555 查看
题意:给出n种货币的面值,每种面值的货币都有无限多个,求不能表示出的货币面值的最小值。若所有面值都能表示则输出-1。
个人感觉吧。这样的题看起来很有趣,但是想出来了又觉得很没意思= =哈哈。看有没有面值为1的货币呗,如果有的话,那么任意面值都能用若干个1加起来表示。如果没有的话,那最小不能表示的面值不就是1么!
题意:给出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; }
相关文章推荐
- Python是什么
- GCD的简单封装
- CCSpawn, CCSequence create函数参数记得用NULL结尾
- Codeforces Round #313 (Div. 2) (ABCDE题解)
- 实现icon和文字垂直居中的两种方法-(vertical-align and line-height)
- Codeforces 559B Equivalent Strings 等价串
- Implement Stack using Queues && Implement Queue using Stacks
- 为什么现在的毕业生那么浮躁呢?
- [Leetcode 108, Meidum] Convert Sorted Array to Binary Search Tree
- 百练oj2703
- codeforces 560C Gerald's Hexagon(找规律)
- [Leetcode 50, Medium] Pow(x, n)
- HDU 1707 Spring-outing Decision
- 浅谈Linux文件操作
- 浅谈Linux文件操作
- [Leetcode 106, Medium] Construct Binary Tree from Inorder and Postorder Traversal
- altium designer 原理图复制出错
- [Leetcode 105, Medium] Construct Binary Tree from Preorder and Inorder Traversal
- poj 3468 A Simple Problem with Integers
- Unity3D之文件读写文件