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 ...
随机推荐
- PHP判断当前访问的是 微信、iphone、android 浏览器
<?phpvar ua = navigator.userAgent.toLowerCase(); if (ua.match(/MicroMessenger/i)=="micromess ...
- 新浪微博的账号登录及api操作
.sina.php <?php /** * PHP Library for weibo.com * * @author */ class sinaPHP { function __constru ...
- web.xml中同一servlet/filter配置多个url-pattern
转自:http://blog.sina.com.cn/s/blog_4c2c2a0c0100dh67.html 若你的servlet要多个地址,或你的filter需要过滤不同的url如有*.jsp,* ...
- linux下epoll如何实现高效处理百万句柄的
linux下epoll如何实现高效处理百万句柄的 分类: linux 技术分享 2012-01-06 10:29 4447人阅读 评论(5) 收藏 举报 linuxsocketcachestructl ...
- 动态平衡二叉搜索树的简易实现,Treap 树
http://blog.csdn.net/qichi_bj/article/details/8232048
- 看懂UML类图与时序图
看懂UML类图和时序图 这里不会将UML的各种元素都提到,我只想讲讲类图中各个类之间的关系: 能看懂类图中各个类之间的线条.箭头代表什么意思后,也就足够应对 日常的工作和交流: 同时,我们应该能将类图 ...
- Xamarin基础命名空间Microsoft.SqlServer.Server
Xamarin基础命名空间Microsoft.SqlServer.Server 该命名空间包含大量的类.接口和枚举,用于操作微软SQL Server数据库.该空间支持Xamarin.iOS和Xam ...
- wpf 触发器,属性触发器,事件触发器,事件触发器。
<EventTrigger RoutedEvent="Mouse.MouseEnter"/> <DataTrigger Binding="{Bindin ...
- Flume interceptor 使用注意事项
1. 在使用 Regex Filtering Interceptor的时候一个属性是excludeEvents 当它的值为true 的时候,过滤掉匹配到当前正则表达式的一行 当它的值为false的时候 ...
- HTML入门第一天
http:超文本标记语言,主要用途是开发网页,使用http展现文字图片 视频 声音 表格 链接……是web网站开发的基础 www(万维网/因特网):world wide web w3c是制定web标准 ...