hdu 5166 Missing number
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5166
Missing number
Description
There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers it lose.
Input
There is a number T shows there are T test cases below. (T≤10)
For each test case , the first line contains a integers n , which means the number of numbers the permutation has. In following a line , there are n distinct postive integers.(1≤n≤1,000)
Output
For each case output two numbers , small number first.
Sample Input
2
3
3 4 5
1
1
Sample Output
1 2
2 3
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
using std::map;
using std::min;
using std::find;
using std::pair;
using std::vector;
using std::multimap;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cls(arr, val) memset(arr, val, sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define tr(c, i) for(iter(c) i = (c).begin(); i != (c).end(); ++i)
const int N = 1010;
const int INF = 0x3f3f3f3f;
bool vis[N];
void solve(int n) {
int v;
vector<int> ans;
cls(vis, false);
rep(i, n) {
scanf("%d", &v);
vis[v] = true;
}
rep(i, n + 2) {
if(!vis[i + 1]) ans.pb(i + 1);
}
printf("%d %d\n", ans[0], ans[1]);
}
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int t, n;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
solve(n);
}
return 0;
}
hdu 5166 Missing number的更多相关文章
- HDU 5166 Missing number 简单数论
Missing number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) [ ...
- hdu 5166 Missing number(。。。)
题意: 有一个排列,但少了两个数.给你少了这两个数的排列.找出是哪两个数. 思路: 看代码,,, 代码: int a[1005]; int main(){ int T; cin>>T; w ...
- HDU 5166(缺失数查找输出)
HDU 5166 Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Description T ...
- Leetcode-268 Missing Number
#268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find ...
- hdu 5898 odd-even number 数位DP
传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 ...
- Missing number
Missing number 题目: Description There is a permutation without two numbers in it, and now you know wh ...
- 【LeetCode】268. Missing Number
Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...
- hdu 2665 Kth number
划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<strin ...
- Missing Number, First Missing Positive
268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find th ...
随机推荐
- Flex 中文字体终极解决方案
一直以来Flash对中文的支持就不是很好,很多人都发现很多汉字在Flex中无法设置粗体,就是其中一个表现,经过一晚上的折腾,终于突破了这个难题,其实,答案就在Adobe的官方教程里,只能怪自己英文水平 ...
- IBM Tivoli NetView网管软件实战
广大网络管理者需要一款包括网络监控故障处理的一个集成网络管理平台,本文根据作者多年实践提出的基于IBM Tivoli Netview的综合网络管理平台,IBM Tivoli与Cisco一直保持着良好的 ...
- angular $apply()以及$digest()讲解
重点的东西放上面,说三遍: 记住的最重要的是ng是否能检测到你对于model的修改.如果它不能检测到,那么你就需要手动地调用$apply()! 记住的最重要的是ng是否能检测到你对于model的修改. ...
- APUE第一章_课后习题
/* 未完成的:1.5 不过在下文中已经给出了解答. */ 1.1 在系统上查证,除根目录外,目录.和..是不同的 ans:这个很容易,用vim打开.和..就可以看到区别. 1.2 分析程序清单1-4 ...
- JavaScript编程规范
最近看NodeJS中,有一部分写JS约定俗成的编程规范(附录B,详情参考附件),感觉在实际工作中能用到, 大致意思分享给大家,详情参考附件: 1.缩进:建议两空格 作为Node.js代码的缩进标记: ...
- Python之路【第五篇】:面向对象及相关
Python之路[第五篇]:面向对象及相关 面向对象基础 基础内容介绍详见一下两篇博文: 面向对象初级篇 面向对象进阶篇 其他相关 一.isinstance(obj, cls) 检查是否obj是否 ...
- .NET中的访问修饰符
.NET中一共有五种访问修饰符 分别是 public 公共的,访问权限最高的. private ...
- CentOS安装中文输入法
yum install "@Chinese Support" System->Preferences->Input Method,勾选"Enable inpu ...
- c++强制类型转换(static_cast,const_cast,dynamic_cast,reinterpret_cast)
static_cast <typeid>(exdlvssion) static_cast 很像 C 语言中的旧式类型转换.它能进行基础类型之间的转换,也能将带有可被单参调用的构造函数或用户 ...
- DOS终端不能使用JAVA命令
DOS 终端 java 命令OK javac 命令OK java version 命令OK 写了小程序HelloWorld 测试 ,文件名HelloWorld.java public class H ...