Missing number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

【Problem 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】

【Sample Output】

 

【题意】

找出一个数列中缺的两个数。

【分析】

本来没啥好说的,记录完了之后O(n)扫描一遍即可,启发就是一种简单的O(1)的算法也要多多注意下。

Sum(n)    =n*(n+)/
Sum(n^) =n*(n+)*(2n+)/

HDU 5166 Missing number 简单数论的更多相关文章

  1. hdu 5166 Missing number

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5166 Missing number Description There is a permutatio ...

  2. hdu 5166 Missing number(。。。)

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

  3. PAT 1144 The Missing Number[简单]

    1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...

  4. HDU 1018 Big Number(数论,Stirling公式)

    1. 利用数学公式lg(n!)=lg(2)+lg(3)+....+lg(n) 求解 2.

  5. Least Common Multiple (HDU - 1019) 【简单数论】【LCM】【欧几里得辗转相除法】

    Least Common Multiple (HDU - 1019) [简单数论][LCM][欧几里得辗转相除法] 标签: 入门讲座题解 数论 题目描述 The least common multip ...

  6. HDU 1005 Number Sequence(数论)

    HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, ...

  7. 七夕节 (HDU - 1215) 【简单数论】【找因数】

    七夕节 (HDU - 1215) [简单数论][找因数] 标签: 入门讲座题解 数论 题目描述 七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们 ...

  8. (step7.2.1)hdu 1395(2^x mod n = 1——简单数论)

    题目大意:输入一个整数n,输出使2^x mod n = 1成立的最小值K 解题思路:简单数论 1)n可能不能为偶数.因为偶数可不可能模上偶数以后==1. 2)n肯定不可能为1 .因为任何数模上1 == ...

  9. PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

随机推荐

  1. first os

    Make your first OS. (MikeOS). check out here

  2. iOS 协同开发出fatal error: file 'XX-Prefix.pch' has been modified since the precompiled header was built

    http://blog.sina.com.cn/s/blog_6f8ed1b90101ake6.html 解决方法 1)http://stackoverflow.com/questions/14793 ...

  3. 贪心+bfs 或者 并查集 Codeforces Round #268 (Div. 2) D

    http://codeforces.com/contest/469/problem/D 题目大意: 给你一个长度为n数组,给你两个集合A.B,再给你两个数字a和b.A集合中的每一个数字x都也能在a集合 ...

  4. 有indexPath获取到cell对象

    //SHSecretaryTipsCell *cell=(SHSecretaryTipsCell *)[tableView cellForRowAtIndexPath:indexPath];

  5. 宏定义重写NSLog

    只需要 在ProjectName_Prefix.pch 中追加你对应的宏定义,不用import 就可以直接使用了. #define DEBUG //宏输出函数 #ifdef DEBUG #define ...

  6. curl continue

    http://www.cyberciti.biz/faq/curl-command-resume-broken-download/

  7. Android BuildConfig.DEBUG的妙用

    在Android开发中,我们使用android.util.Log来打印日志,方便我们的开发调试.但是这些代码不想在发布后执行,我们并不想在软件发布后调试日志被其他开发者看到,现在我的方法是设置一个全局 ...

  8. THE ROAD TO PROGRAM

    <The C Programming Language> <The Practice of Programming><The Art of Computer Progra ...

  9. HTML-中<li>标签value值的兼容问题

    今天在做项目测试的时候,发现IE浏览器对HTML中<li>标记的value取值存在兼容性问题,特意从4个浏览器出发进行了一些测试.现将测试结论展示如下: 测试类型 IE8 FF16.0.1 ...

  10. ShellExecute快捷键大全

    文件夹,文件,网址可以创建快捷方式,控制面板 中的设置也可以创建快捷方式,下面是快捷方式的命令,使用方法:在桌面或文件夹的空白处点右键,选择新建,快捷方式,在"请键入项目的位置"输 ...