Missing number
题目:
Description
Input
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
Sample Input
Sample Output
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=;
int a[maxn];
int main()
{
int T,n,x,j;
int b[];
cin>>T;
while(T--)
{
memset(a,,sizeof(a));
cin>>n;
for(int i=;i<n;i++)
{cin>>x;
a[x]=;
}
j=;
for(int k=;k<=n+;k++)
if(!a[k])
b[j++]=k;
cout<<b[]<<' '<<b[]<<endl;
}
return ;
}
Missing number的更多相关文章
- Leetcode-268 Missing Number
#268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find ...
- 【LeetCode】268. Missing Number
Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...
- hdu 5166 Missing number
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5166 Missing number Description There is a permutatio ...
- Missing Number, First Missing Positive
268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find th ...
- HDU 5166 Missing number 简单数论
Missing number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) [ ...
- Missing number in array
Given an array of size n-1 and given that there are numbers from 1 to n with one missing, the missin ...
- PAT 1144 The Missing Number
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- [LintCode] Find the Missing Number 寻找丢失的数字
Given an array contains N numbers of 0 .. N, find which number doesn't exist in the array. Example G ...
- PAT 1144 The Missing Number[简单]
1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...
随机推荐
- (C#基础) byte[] 之初始化, 赋值,转换。(转)
byte[] 之初始化赋值 用for loop 赋值当然是最基本的方法,不过在C#里面还有其他的便捷方法. 1. 创建一个长度为10的byte数组,并且其中每个byte的值为0. byte[] myB ...
- js日期格式化
<html> <head> <script> function test(){ //Js获取当前日期时间及其它操作 var myDate = new Date(); ...
- Linux学习笔记(16)shell基础之Bash变量
1. 用户自定义变量 (1)变量设置规则 ① 变量名称可由字母.数字和下划线组成,但不能以数字开头: ② 变量的默认类型为字符串类型,如果要对数值运算,则必须指定变量类型为数值型: ③ 变量用等号连接 ...
- 三层+MVC导出Excel(2)
背景: 出门在外,一切以健康为主,学习为辅,健康搞好了,学习也不能拉下,在外工作期间,我们在做数据导出的时候,自己封了一个类,利用NPOI进行数据导出Excel,自我感觉良好,特给大家分享一下,希望对 ...
- 【J2EE入门】13个规范
看过了j2ee教学视频,真的让我痛彻心扉,那叫痛并快乐着,痛是因为看了这么长时间,自己只知道了13个规范的概念:同样,快乐也正是因为我知道了13个规范的概念,接下来就是逐项实践的学习. 看了教学视频, ...
- RPC和Socket,RMI和RPC之间的关系
远程通信机制RPC与RMI的关系 http://blog.csdn.net/zolalad/article/details/25161133 1.RPC RPC(Remote Proced ...
- EM css
原文地址http://www.uml.org.cn/html/201207311.asp CSS中强大的EM 作者:dearjohn ,发布于2012-7-31, ...
- shell-bash学习04读取输入、分隔符、流程控制
读入输出 输入通常是通过stdin或参数传递给命令; 输出出现在stderr或stdout; 管道,过滤器,管道操作符: cmd1 | cmd2 | cmd3; //最后还有输出 ls | cat - ...
- Thymeleaf 常用属性
Thymeleaf 常用属性 如需了解thymeleafThymeleaf 基本表达式,请参考<Thymeleaf 基本表达式>一文 th:action 定义后台控制器路径,类似<f ...
- 在Windows宿主机中连接虚拟机中的Docker容器
1. 简单拓扑图