zoukankan      html  css  js  c++  java
  • 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. (T10)
    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.(1n1,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
    ", 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;
    }
  • 相关阅读:
    MKMapVIew学习系列2 在地图上绘制出你运行的轨迹
    WPF SDK研究 Intro(6) WordGame1
    WPF SDK研究 Intro(3) QuickStart3
    WPF SDK研究 Layout(1) Grid
    WPF SDK研究 目录 前言
    WPF SDK研究 Intro(7) WordGame2
    WPF SDK研究 Layout(2) GridComplex
    对vs2005创建的WPF模板分析
    WPF SDK研究 Intro(4) QuickStart4
    《Programming WPF》翻译 第6章 资源
  • 原文地址:https://www.cnblogs.com/GadyPu/p/4796215.html
Copyright © 2011-2022 走看看