Unique Ascending Array


Time Limit: 2 Seconds      Memory Limit: 65536 KB


Given an array of integers A[N], you are asked to decide the shortest array of integers B[M], such that the following two conditions hold.

  • For all integers 0 <= i < N, there exists an integer 0 <= j < M, such that A[i] == B[j]
  • For all integers 0 =< i < j < M, we have B[i] < B[j]

Notice that for each array A[] a unique array B[] exists.

Input

The input consists of several test cases. For each test case, an integer N (1 <= N <= 100) is given, followed by N integers A[0], A[1], ..., A[N - 1] in a line. A line containing only
a zero indicates the end of input.

Output

For each test case in the input, output the array B in one line. There should be exactly one space between the numbers, and there should be no initial or trailing spaces.

Sample Input

8 1 2 3 4 5 6 7 8

8 8 7 6 5 4 3 2 1

8 1 3 2 3 1 2 3 1

0

Sample Output

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8

1 2 3

————————————————————————————————————

题目的意思是给出一个序列,输出去重后的排序好的序列

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue> using namespace std;
#define inf 0x3f3f3f3f int main()
{
int n,a[100005];
while(~scanf("%d",&n)&&n)
{
for(int i=0; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
printf("%d",a[0]);
for(int i=1; i<n; i++)
if(a[i]!=a[i-1])
printf(" %d",a[i]);
printf("\n");
}
return 0;
}

最新文章

  1. 用Kotlin开发Android应用(II):创建新项目
  2. sql server cross/outer apply 用法
  3. BOOL和bool的区别
  4. NPOI 单元格(cell) 格式参数
  5. (七)理解angular中的module和injector,即依赖注入
  6. 部署keepalive+lvs
  7. 使用DialogFragment创建对话框总结
  8. 【转】ExcelHelper类,用npoi读取Excel文档
  9. hello MemSQL 入门安装演示样例
  10. 旅游[SPFA或是最小生成树][简单算法的灵活题]
  11. JPA + SpringData 操作数据库原来可以这么简单 ---- 深入了解 JPA - 1
  12. rails关于一个Action的多次或多个Action之间共享数据的思路
  13. .NET Core protobuf-net、MessagePack、Json.NET序列化/反序列化性能测试
  14. DataStructure-链表实现指数非递减一元多项式的求和
  15. 【活动发布】捷微H5-微信新年砍价活动,开源发布了
  16. input的type类型
  17. ROS 错误之 [rospack] Error: package &#39;beginner_tutorials&#39; not found
  18. Java 8 – StringJoiner example
  19. 数据结构&amp;堆&amp;heap&amp;priority_queue&amp;实现
  20. C++编程 - tuple、any容器

热门文章

  1. chrome innerHTML赋值
  2. 吴裕雄 数据挖掘与分析案例实战(8)——Logistic回归分类模型
  3. python文件的只读,只写操作
  4. 精确除法:from __future__ import division
  5. 分享至微信、QQ、微博、复制链接
  6. centos 系统下彻底删除mysql
  7. 测试SQL
  8. [leetcode]113. Path Sum II路径和(返回路径)
  9. Spring基于AspectJ的AOP的开发之AOP的相关术语
  10. Connecting to MQSeries with .NET