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 ...
随机推荐
- apache https配置步骤
转自:http://www.cnblogs.com/best-jobs/p/3298258.html 1. 确认是否安装ssl模块 是否有mod_ssl.so文件 2. 生成证书和密钥 linux ...
- 链接器工具错误 LNK2026 XXX模块对于 SAFESEH 映像是不安全的
解决方法: 1.打开该项目的"属性页"对话框. 2.单击"链接器"文件夹. 3.单击"命令行"属性页. 4.将 /SAFESEH:NO 键入 ...
- Codeforces Round #14 D. Two Paths(求树上两条不相交的路径的乘积最大值)
题目链接: http://codeforces.com/problemset/problem/14/D 思路:直接枚举每一天路径的两端,然后求以每一端为树根的树上最长路径,然后相乘就可以了. # ...
- VisualStudio一打开工程就崩溃-重打开output显示We were unable to automatically populate your Visual Studio Online accounts.
and this method exactly effected on me
- Jmeter 小攻略(转)
http://www.myexception.cn/open-source/1346307.html
- 保利威视Polyv点播集成
demo和文档下载地址http://dev.polyv.net/2014/08/sdk/ 1.demo是eclipse的,所以导入android studio有几个要注意的地方 导入方式 在app的b ...
- XStream-----把JavaBean转换为xml的工具
1. 什么作用 可以把JavaBean转换为(序列化为)xml 2. XStream的jar包 核心JAR包:xstream-1.4.7.jar: 必须依赖包:xpp3_min-1.1.4c(XML ...
- 【转】【技术博客】Spark性能优化指南——高级篇
http://mp.weixin.qq.com/s?__biz=MjM5NjQ5MTI5OA==&mid=2651745207&idx=1&sn=3d70d59cede236e ...
- express-2 express介绍
脚手架 大多数项目都需要一定数量的"套路化"代码,所有可以创建一个通用的项目骨架,每次开始新项目时,只需复制这个骨架,或者说是模板. RoR把这个概念向前推进了一步,它提供了一个可 ...
- 分享Kali Linux 2016.2第43周镜像
分享Kali Linux 2016.2第43周镜像Kali Linux官方于10月23日如约发布了2016.2第43周镜像.和以往一样,此次镜像包含了11个镜像文件,包含PC端的32和64位镜像,还有 ...