codeforce 560 A Currency System in Geraldion
来源:互联网 发布:软件定义物联网 编辑:程序博客网 时间:2024/04/29 23:36
题目链接:http://codeforces.com/problemset/problem/560/A
卧槽,这题谁出的,英文学的渣简直就是罪恶。题目看了好久没读懂,以为很难。读了好几遍才发现简直是弱智题。
意思是说:要有一套纸币体系,包含n种币值(a1,a2,…,an.均为正整数),问是否给出的任意数值(正整数)纸币均能表达,若都能则输出“-1”;若存在不能表达的币值,则输出其中最小的值。
思路:如果给出的基础币值体系中含有1,那么试问有哪个正整数不能表示出来呢?而1最小的正整数,本身又不能由其他比它大的数字表示出来,所以只要不含1,那么1肯定不能表示出来。。。所以最终答案不是1就是-1。。。
#include <iostream>#include <cstdio>using namespace std;int main(){ //freopen("input.txt","r",stdin); int n; int a[1010]; while(~scanf("%d",&n)) { int flag=0; for(int i=1; i<=n; i++) { scanf("%d",&a[i]); if(a[i]==1) flag=1; } if(flag) cout<<"-1"<<endl; else cout<<"1"<<endl; } return 0;}
0 0
- codeforce 560 A Currency System in Geraldion
- codeforces 560 A. Currency System in Geraldion
- CodeForces 560A Currency System in Geraldion
- CodeForces 560A Currency System in Geraldion
- coderforce 560A Currency System in Geraldion
- CodeForces 560A Currency System in Geraldion
- CodeForces 560A Currency System in Geraldion
- CodeForces 560A Currency System in Geraldion
- CodeForces - 560A Currency System in Geraldion
- A. Currency System in Geraldion
- Codeforces 560A Currency System in Geraldion 货币组合
- Codeforces 560 A. Currency System in Geraldion(想法题)
- Code Forces 560 A. Currency System in Geraldion(水~)
- CodeForces 560A-Currency System in Geraldion
- CodeForces 560A Currency System in Geraldion 【水题】
- 【63.73%】【codeforces 560A】Currency System in Geraldion
- CodeForces#313 A. Currency System in Geraldion
- Currency System in Geraldion
- 搞对象前,你得先有对象
- 汉字转码
- 海外对冲基金多地开花QDIE QDLP各领风骚
- 进程与线程的区别
- appium安装过程中遇到的困难
- codeforce 560 A Currency System in Geraldion
- chrome jsonView插件安装
- QDIE
- 常用的arm汇编指令(2)
- drop、truncate和delete的区别
- 处理键盘通知
- Oracle函数列表速查
- 如何处理需要填充的数据为空的情况?
- QDLP