题目链接: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. C++对象模型6--对象模型对数据访问的影响

    如何访问成员? 前面介绍了C++对象模型,下面介绍C++对象模型的对访问成员的影响.其实清楚了C++对象模型,就清楚了成员访问机制.下面分别针对数据成员和函数成员是如何访问到的,给出一个大致介绍. 对 ...

  2. Jquery对select的操作(附日历天数变化代码)

    转载请注明出处. 逃不开传统的四种操作:增.删.改.查. <四处搜刮了jquery对select操作的代码,汇集一下,方便以后查看.日历天数变化代码为原创.> [增]: $("# ...

  3. 图片剪切之Croppic插件

    前几天做图片上传时需要进行图片的剪切和缩放,上网查找时找到了这个插件.样式很好看,功能也很OK.但是网上都是php进行后台处理图片的例子,然后只好慢慢琢磨C#的处理.插件地址是:http://www. ...

  4. CRM中的一个函数,保存一下,别系统被ぅ崩坏就麻烦了.

    CREATE OR REPLACE function UXQLCRM.GET_WEI_XIU(htfid in varchar2) ); CURSOR cr_bg_jl is select " ...

  5. Symfony命令行

    Available commands:  help                                  显示命令的帮助信息  list                           ...

  6. C文件操作(转载)

    /*1.文件的打开(fopen函数)fopen函数用来打开一个文件,其调用的一般形式为:文件指针=fopen(文件名,文件操作方式):例如:FILE *fpinfpin=fopen("c:\ ...

  7. document.createElement在IE和Firefox下的差异

    IE有3种方式都可以创建一个元素: 1 document.createElement("<input type=text>") 2 document.createEle ...

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

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

  9. BZOJ 1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚

    题目 1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚 Time Limit: 5 Sec  Memory Limit: 64 MB Description Farm ...

  10. 【LeetCode】Flatten Binary Tree to Linked List

    随笔一记,留做重温! Flatten Binary Tree to Linked List Given a binary tree, flatten it to a linked list in-pl ...