题目连接

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的更多相关文章

  1. HDU 5166 Missing number 简单数论

    Missing number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) [ ...

  2. hdu 5166 Missing number(。。。)

    题意: 有一个排列,但少了两个数.给你少了这两个数的排列.找出是哪两个数. 思路: 看代码,,, 代码: int a[1005]; int main(){ int T; cin>>T; w ...

  3. HDU 5166(缺失数查找输出)

    HDU 5166 Time Limit:1000MS  Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description T ...

  4. Leetcode-268 Missing Number

    #268.  Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find ...

  5. hdu 5898 odd-even number 数位DP

    传送门:hdu 5898 odd-even number 思路:数位DP,套着数位DP的模板搞一发就可以了不过要注意前导0的处理,dp[pos][pre][status][ze] pos:当前处理的位 ...

  6. Missing number

    Missing number 题目: Description There is a permutation without two numbers in it, and now you know wh ...

  7. 【LeetCode】268. Missing Number

    Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...

  8. hdu 2665 Kth number

    划分树 /* HDU 2665 Kth number 划分树 */ #include<stdio.h> #include<iostream> #include<strin ...

  9. Missing Number, First Missing Positive

    268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find th ...

随机推荐

  1. 返回顶部js

    backToTop.js: (function () { var $backToTopEle = $('<div class="backToTop"></div& ...

  2. TCP/IP详解学习笔记(14)-- TCP可靠传输的实现

    1.概述      为方便描述可靠传输原理,假定数据传输只在一个方向上进行,即A发送数据,B给出确认 2.以字节为单位的滑动窗口      TCP的滑动窗口是以字节为单位的.为了便于说明,字节编号取得 ...

  3. PAT1099

    /*innner order traverse for BST will be ordered *1.sort the value in buffer *2.inner traverse the BS ...

  4. JS跳转到顶部的方法

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>J ...

  5. markdown语法学习效果预览

    注: 结合markdown官方文档 其中大部分例子和说明文字都摘自官方文档 官方链接:Markdown: Basics (快速入门). 一 段落.标题.区块代码 Markdown 支持两种标题的语法, ...

  6. A Neural Probabilistic Language Model

    A Neural Probabilistic Language Model,这篇论文是Begio等人在2003年发表的,可以说是词表示的鼻祖.在这里给出简要的译文 A Neural Probabili ...

  7. 设计模式-原型模式(Prototype)

    场景分析: 前面我们提到,交易对象Trade,还有继承他的债券交易BondTrade.期货交易FutureTrade. 现在有一个需求,需要提供方法将交易拆分成多笔小交易. 代码如下(如果没有clon ...

  8. Visitor

    #include <iostream> #include <vector> using namespace std; #define DESTROY_POINTER(ptr) ...

  9. js 定位到指定位置

     <script>    //滚动定位到product         function scroll() {             var scroll_offset = $(&quo ...

  10. ref和out的区别,值类型和引用类型的使用

    今天刚刚明白ref和out的区别,只限于个人理解如有不同请赐教,谢谢 首先我感觉ref和out是针对于值类型来说,以前一直认为是针对于引用类型看下面的一段代码 1.首先结果 i=0:ints[0]=0 ...