题目链接:http://acm.swust.edu.cn/problem/0234/

Time limit(ms): 1000        Memory limit(kb): 65535
 
Description
You are given a list of number. An integer K is irreducible with respect to the numbers if K cannot be represented as 
a sum of one or more elements from the numbers, where each element of the numbers may be used at most once. Return 
the smallest positive integer that is irreducible with respect to the given numbers.

 
Input
n: the size of the numbers, -1 indicates end. (1 =< n <= 3) 
next line contains n numbers (1 =< number <= 100)

 
Output
the smallest positive integer that is irreducible with respect to the given numbers.

 
Sample Input
2
1 1
2
1 2
-1
Sample Output
3
4
 
SCPC__张剑
 
题目大意:题意是这样的,输入n(n!=-1),接下来n个数,凡是这些数和它们相加能得到的数字都不能使用,从1开始遍历,把能使用的最小的数输出来~~~
 
代码如下:
由于最多3个数
 #include <iostream>
using namespace std;
int a[], vis[];
int main(){
int n, i;
while (cin >> n, n != -){
memset(vis, , sizeof(vis));
for (i = ; i <= n; i++){
cin >> a[i];
vis[a[i]] = ;
}
if (n == ){
vis[a[] + a[]] = ;
}
else{
vis[a[] + a[]] = ;
vis[a[] + a[]] = ;
vis[a[] + a[]] = ;
vis[a[] + a[] + a[]] = ;
}
for (i = ;; i++)
if (!vis[i]) {
cout << i << endl;
break;
}
}
return ;
}

其实多简单的,就是题意太坑了有木有~~~

[Swust OJ 234]--IrreducibleNumber(题意太坑)的更多相关文章

  1. [Swust OJ 649]--NBA Finals(dp,后台略(hen)坑)

    题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 Consider two ...

  2. SWUST OJ NBA Finals(0649)

    NBA Finals(0649) Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 404 Accepted: 128   Descri ...

  3. js 赋值 要用 toString() ; 太坑了。

    js 赋值 要用 toString() ;     太坑了. js 赋值 要用 toString() ;     太坑了. js 赋值 要用 toString() ;     太坑了.

  4. [Swust OJ 404]--最小代价树(动态规划)

    题目链接:http://acm.swust.edu.cn/problem/code/745255/ Time limit(ms): 1000 Memory limit(kb): 65535   Des ...

  5. 太坑了,mybatis注解一对多,id没了

    @Select("SELECT *, id nodes FROM QUESTION_PO WHERE ID=#{id}") @Results({ @Result(property ...

  6. [Swust OJ 188]--异面空间(读懂题意很重要)

    题目链接:http://acm.swust.edu.cn/problem/188/ Time limit(ms): 1000 Memory limit(kb): 65535   江鸟来到了一个很奇怪的 ...

  7. [Swust OJ 1125]--又见GCD(数论,素数表存贮因子)

    题目链接:http://acm.swust.edu.cn/problem/1125/ Time limit(ms): 1000 Memory limit(kb): 65535   Descriptio ...

  8. [Swust OJ 1126]--神奇的矩阵(BFS,预处理,打表)

    题目链接:http://acm.swust.edu.cn/problem/1126/ Time limit(ms): 1000 Memory limit(kb): 65535 上一周里,患有XX症的哈 ...

  9. [Swust OJ 893]--Blocks

    题目链接:http://acm.swust.edu.cn/problem/893/ Time limit(ms): 1000 Memory limit(kb): 65535   Josh loves ...

随机推荐

  1. radio与checkbox的选中事件

    <一>判断checkbox的选中事件 var result=$(this).find("input[type='checkbox']").prop("chec ...

  2. Servlet url-pattern优先级

    完全匹配>目录匹配>扩展名匹配

  3. OpenGL: 环境配置和图元的绘制

    前言 距离上一篇博客已经过去一个半月了,这段时间过得确实充实,虽然一大段时间泡在图书馆复习,但至少也能学到点东西.跨年晚和元旦一整天,全身心投入图形学小课设的编程,终于实现了老师要求的所有功能,回想起 ...

  4. @Transactional失效的问题

    spring事物配置一般没有问题, 优先检查mysql的引擎是否是innodb, 是的话检查包的扫描是否有问题. 我就是因为包的扫描导致@Transactional失效. 具体情况如下, 在sprin ...

  5. MVC-03 控制器(2)

    五.ActionResult解说 ActionResult的继承图: 类型 Controller辅助方法 用途帮助 ContentResult Content 回传一个用户自定义的文字属性 Empty ...

  6. RFID电子标签制造封装工艺和可靠性研究

    一.目的和意义 电子标签已经成为RFID工业的主要焦点 实现低成本.大批量.高可靠性地制造电子标签是推广RFID产品应用的关键技术之一 针对RFID标签制造中核心的封装工艺开展研究,以各向异性导 ...

  7. Qt 智能指针学习(7种QT的特有指针)

    从内存泄露开始? 很简单的入门程序,应该比较熟悉吧 ^_^ #include <QApplication> #include <QLabel> int main(int arg ...

  8. php浮点数计算比较及取整不准确解决方法

    原文:php浮点数计算比较及取整不准确解决方法 php有意思的现象,应该是很多编程语言都会有这样的现象.这个是因为计算机的本身对浮点数识别的问题..... $f = 0.58; var_dump(in ...

  9. makinacorpus/spynner

    makinacorpus/spynner Intro Contents Intro Credits Companies Authors Contributors Dependencies Feedba ...

  10. 阵列中条带(stripe)、stripe unit

    摘抄:http://blog.sina.com.cn/s/blog_4a362d610100aed2.html 在磁盘阵列中,数据是以条带(stripe)的方式贯穿在磁盘阵列所有硬盘中的.这种数据的分 ...