题目链接: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. [LeetCode]题解(python):115-Distinct Subsequences

    题目来源: https://leetcode.com/problems/distinct-subsequences/ 题意分析: 给定字符串S和T,判断S中可以组成多少个T,T是S的子串. 题目思路: ...

  2. python10min系列之面试题解析:python实现tail -f功能

    同步发布在github上,跪求star 这篇文章最初是因为reboot的群里,有人去面试,笔试题有这个题,不知道怎么做,什么思路,就发群里大家讨论 我想了一下,简单说一下我的想法吧,当然,也有很好用的 ...

  3. 什么是weblogic?安装步骤详解

    weblogic,就是用于java开发的web服务器. tomcat熟悉吧,跟tomcat一个作用,是比tomcat更具优势的web服务器. 安装:(转载) 1.提供安装文件网盘下载:链接处2.安装过 ...

  4. DropBox为什么一直那么红——靠用户体验,旗帜鲜明,它要保存的是你的重要随身资料,并且开放API

    链接:http://www.zhihu.com/question/19705960/answer/71742127来源:知乎 看到这个问题竟然从11年答到现在,有趣的是这几年里国内云存储行业变化也是蛮 ...

  5. android studio recent projects

    android studio正常的删除项目的方法是可以点击右键,选择project structure,进入到界面时,选择你要删除的工程,点击减号,接着就可以右键工程有一个delete. 另外一种方法 ...

  6. 代码收藏 JS实现页内查找定位功能

    前部分为IE下搜索方法 用TextRange来实现 后部分为firefox.chrome下搜索方法 var nextIndex = 0; var searchValue = ''; var input ...

  7. HDOJ 1429 胜利大逃亡(续) (bfs+状态压缩)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1429 思路分析:题目要求找出最短的逃亡路径,但是与一般的问题不同,该问题增加了门与钥匙约束条件: 考虑 ...

  8. CF 459A(Pashmak and Garden-正方形给出2点求2点)

    A. Pashmak and Garden time limit per test 1 second memory limit per test 256 megabytes input standar ...

  9. 文件下载 .net

    protected void Button1_Click(object sender, EventArgs e)  { /* 微软为Response对象提供了一个新的方法TransmitFile来解决 ...

  10. PreTranslateMessage和TranslateMessage区别(转)

    PreTranslateMessage是消息在送给TranslateMessage函数之前被调用的,绝大多数本窗口的消息都要通过这里,比较常用,当需要在MFC之前处理某些消息时,常常要在这里添加代码. ...